[PATCH] Handle sha1_object_info failures in ls-tree -l

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Printing 0 as the size of the blob seem to be the safest. The error
message is already printed by sha1_object_info itself.

Signed-off-by: Alex Riesen <raa.lkml@xxxxxxxxx>
---
jidanni@xxxxxxxxxxx, Fri, Jan 02, 2009 00:18:42 +0100:
> git ls-tree prints wacko file sizes if it can't find the blob:
> $ git ls-tree --abbrev=4 -l 76e4
> error: unable to find ae832f2245892ddde5221357466448b409775142
> 100644 blob ae83 3220821896     words

Not tested, but should print size of 0 if this happens.
I actually would prefer ls-tree finish listing and exit(1) in this case,
but ... am a little lazy (or scared of a "static int exit_code;").

 builtin-ls-tree.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c
index cb61717..234df50 100644
--- a/builtin-ls-tree.c
+++ b/builtin-ls-tree.c
@@ -96,7 +96,8 @@ 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) {
 			if (!strcmp(type, blob_type)) {
-				sha1_object_info(sha1, &size);
+				if (sha1_object_info(sha1, &size))
+					size = 0;
 				printf("%06o %s %s %7lu\t", mode, type,
 				       abbrev ? find_unique_abbrev(sha1, abbrev)
 				              : sha1_to_hex(sha1),
-- 
1.6.1.73.g7450

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux