diff options
author | Alex Riesen <raa.lkml@gmail.com> | 2009-03-19 23:54:29 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-20 09:35:21 -0700 |
commit | e392a852364e375e916c1dd4f87a7584b348410a (patch) | |
tree | ed4e23931e07e5c2c25a0fcbc56437d60a74a45a /builtin-ls-tree.c | |
parent | import-tars: separate author from committer (diff) | |
download | tgif-e392a852364e375e916c1dd4f87a7584b348410a.tar.xz |
Produce a nicer output in case of sha1_object_info failures in ls-tree -l
An error message is already printed by sha1_object_info itself, and
the failed entries are additionally marked in the listing.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-ls-tree.c')
-rw-r--r-- | builtin-ls-tree.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c index fca46312f6..22008dfa8f 100644 --- a/builtin-ls-tree.c +++ b/builtin-ls-tree.c @@ -60,7 +60,6 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen, { int retval = 0; const char *type = blob_type; - unsigned long size; if (S_ISGITLINK(mode)) { /* @@ -90,17 +89,20 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen, if (!(ls_options & LS_NAME_ONLY)) { if (ls_options & LS_SHOW_SIZE) { + char size_text[24]; if (!strcmp(type, blob_type)) { - sha1_object_info(sha1, &size); - printf("%06o %s %s %7lu\t", mode, type, - abbrev ? find_unique_abbrev(sha1, abbrev) - : sha1_to_hex(sha1), - size); + unsigned long size; + if (sha1_object_info(sha1, &size) == OBJ_BAD) + strcpy(size_text, "BAD"); + else + snprintf(size_text, sizeof(size_text), + "%lu", size); } else - printf("%06o %s %s %7c\t", mode, type, - abbrev ? find_unique_abbrev(sha1, abbrev) - : sha1_to_hex(sha1), - '-'); + strcpy(size_text, "-"); + printf("%06o %s %s %7s\t", mode, type, + abbrev ? find_unique_abbrev(sha1, abbrev) + : sha1_to_hex(sha1), + size_text); } else printf("%06o %s %s\t", mode, type, abbrev ? find_unique_abbrev(sha1, abbrev) |