All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: jidanni@jidanni.org
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] Handle sha1_object_info failures in ls-tree -l
Date: Fri, 2 Jan 2009 00:52:00 +0100	[thread overview]
Message-ID: <20090101235200.GA14713@blimp.localdomain> (raw)
In-Reply-To: <87eizmty25.fsf_-_@jidanni.org>

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@gmail.com>
---
jidanni@jidanni.org, 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

  parent reply	other threads:[~2009-01-01 23:53 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-19 19:29 How to extract files out of a "git bundle", no matter what? jidanni
2008-12-19 19:32 ` Shawn O. Pearce
2008-12-19 19:57   ` Mark Levedahl
2008-12-19 20:13     ` jidanni
2008-12-19 20:21       ` Jeff King
2008-12-19 20:35         ` jidanni
2008-12-19 20:51           ` Jeff King
2009-01-01  4:24             ` [PATCH] Documentation/git-bundle.txt: Dumping contents of any bundle jidanni
2009-01-01 17:03               ` Johannes Schindelin
2009-01-01 19:21               ` Jeff King
2009-01-01 22:12                 ` jidanni
2009-01-01 23:48                   ` Jeff King
2009-01-02  0:10                     ` jidanni
2009-01-02  7:15                       ` Shawn O. Pearce
2009-01-02  8:27                         ` Jeff King
2009-01-02 22:03                           ` jidanni
2009-01-01 23:18                 ` git ls-tree prints wacko file sizes if it can't find the blob jidanni
2009-01-01 23:47                   ` jidanni
2009-01-01 23:52                   ` Alex Riesen [this message]
2009-01-26 19:02       ` [PATCH] git-bundle(1): add no references required simplest case jidanni
2009-01-26 19:53         ` Junio C Hamano
2009-01-29 15:32           ` [PATCH,v2] " jidanni
2009-02-01 23:42             ` jidanni
2009-02-02  0:04               ` Johannes Schindelin
2009-02-02  0:45                 ` Junio C Hamano
2009-02-04  0:09                   ` jidanni
2009-02-04  2:07                     ` Junio C Hamano
2009-02-04  2:18                       ` jidanni
2009-02-04  9:15                       ` [PATCH] git-bundle doc: update examples Nanako Shiraishi
2009-02-04 15:26                         ` Jeff King
2009-02-04 22:44                         ` Junio C Hamano
2008-12-19 20:07 ` How to extract files out of a "git bundle", no matter what? Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090101235200.GA14713@blimp.localdomain \
    --to=raa.lkml@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jidanni@jidanni.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.