Skip to content

Commit

Permalink
[PATCH] git-cat-file: use sha1_object_info() on '-t'.
Browse files Browse the repository at this point in the history
When trying to find out the type of the object, there is no need
to uncompress the whole object.  Just use sha1_object_info().

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Junio C Hamano authored and Linus Torvalds committed Jun 28, 2005
1 parent 5db47c2 commit f2a0633
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ int main(int argc, char **argv)
usage("git-cat-file [-t | tagname] <sha1>");

if (!strcmp("-t", argv[1])) {
buf = read_sha1_file(sha1, type, &size);
if (buf) {
buf = type;
size = strlen(type);
type[size] = '\n';
size++;
if (!sha1_object_info(sha1, type, &size)) {
printf("%s\n", type);
return 0;
}
buf = NULL;
} else {
buf = read_object_with_reference(sha1, argv[1], &size, NULL);
}
Expand Down

0 comments on commit f2a0633

Please sign in to comment.