aboutsummaryrefslogtreecommitdiffstats
path: root/cat-file.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-06-27 23:58:45 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-28 08:53:21 -0700
commitf2a06330f0bc259b9c7faa029d2d4dace8f4956b (patch)
treec508d4f45105cf1b989f76097ef49bb6fc298708 /cat-file.c
parent5db47c2bb3b7e77fd32aeef12b6f6de8d14cb43b (diff)
downloadgit-f2a06330f0bc259b9c7faa029d2d4dace8f4956b.tar.gz
[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>
Diffstat (limited to 'cat-file.c')
-rw-r--r--cat-file.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/cat-file.c b/cat-file.c
index be41f51666..0076fc5b20 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] <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);
}