Browse Source

[PATCH] git-cat-file: use sha1_object_info() on '-t'.

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>
maint
Junio C Hamano 20 years ago committed by Linus Torvalds
parent
commit
f2a06330f0
  1. 10
      cat-file.c

10
cat-file.c

@ -16,13 +16,11 @@ int main(int argc, char **argv)
usage("git-cat-file [-t | tagname] <sha1>"); usage("git-cat-file [-t | tagname] <sha1>");


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

Loading…
Cancel
Save