Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH 2/6] show-diff.c: check unreadbale blob.
Date: Mon, 18 Apr 2005 13:34:02 -0700	[thread overview]
Message-ID: <7vr7h7u8n9.fsf@assigned-by-dhcp.cox.net> (raw)

[PATCH 2/6] show-diff.c: check unreadbale blob.

This patch fixes show-diff to detect unreadable blob and warn
instead of going ahead and crashing.

To be applied on top of:

    [PATCH 1/6] show-diff.c: clean up private buffer use.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

 show-diff.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletion(-)

--- a/show-diff.c
+++ b/show-diff.c
@@ -71,6 +71,11 @@ static void show_diff_empty(struct cache
 	unsigned char type[20], *p, *end;
 
 	old = read_sha1_file(ce->sha1, type, &size);
+	if (! old) {
+		error("unable to read blob object for %s (%s)", ce->name,
+		      sha1_to_hex(ce->sha1));
+		return;
+	}
 	if (size > 0) {
 		int startline = 1;
 		int c = 0;
@@ -195,7 +200,11 @@ int main(int argc, char **argv)
 			continue;
 
 		old = read_sha1_file(ce->sha1, type, &size);
-		show_differences(ce->name, old, size);
+		if (! old)
+			error("unable to read blob object for %s (%s)",
+			      ce->name, sha1_to_hex(ce->sha1));
+		else
+			show_differences(ce->name, old, size);
 		free(old);
 	}
 	return 0;


                 reply	other threads:[~2005-04-18 20:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=7vr7h7u8n9.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox