From: Junio C Hamano Date: Tue, 28 Jun 2005 06:58:45 +0000 (-0700) Subject: [PATCH] git-cat-file: use sha1_object_info() on '-t'. X-Git-Tag: v0.99~146 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=f2a06330f0bc259b9c7faa029d2d4dace8f4956b;p=git.git [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 Signed-off-by: Linus Torvalds --- diff --git a/cat-file.c b/cat-file.c index be41f5166..0076fc5b2 100644 --- a/cat-file.c +++ b/cat-file.c @@ -16,13 +16,11 @@ int main(int argc, char **argv) usage("git-cat-file [-t | tagname] "); 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); }