summaryrefslogtreecommitdiff
path: root/show-diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-04-18 15:07:24 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-18 15:07:24 -0700
commitd0db466326c32ca4b3faa849a81fab7d60615c6f (patch)
tree7adca356fd5756abecd4e38e10e806d9ecaabea6 /show-diff.c
parentc157d376740f224789f464785718f3757ea8aa92 (diff)
downloadgit-d0db466326c32ca4b3faa849a81fab7d60615c6f.tar.gz
[PATCH] show-diff.c: check unreadbale blob.
This patch fixes show-diff to detect unreadable blob and warn instead of going ahead and crashing. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'show-diff.c')
-rw-r--r--show-diff.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/show-diff.c b/show-diff.c
index 2bd789c261..dacdd36394 100644
--- a/show-diff.c
+++ b/show-diff.c
@@ -71,6 +71,11 @@ static void show_diff_empty(struct cache_entry *ce)
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;