summaryrefslogtreecommitdiff
path: root/builtin/tag.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-02-06 08:13:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-02-06 18:00:51 (GMT)
commitfb630e048c6efabe4d46b1b125fe7348062d38e6 (patch)
tree1034df77904ed92fd9d0049f9eeec6de08324c2c /builtin/tag.c
parentca51699961664890fdaabd276af539e6b3514053 (diff)
downloadgit-fb630e048c6efabe4d46b1b125fe7348062d38e6.zip
git-fb630e048c6efabe4d46b1b125fe7348062d38e6.tar.gz
git-fb630e048c6efabe4d46b1b125fe7348062d38e6.tar.bz2
tag: die when listing missing or corrupt objects
We don't usually bother looking at tagged objects at all when listing. However, if "-n" is specified, we open the objects to read the annotations of the tags. If we fail to read an object, or if the object has zero length, we simply silently return. The first case is an indication of a broken or corrupt repo, and we should notify the user of the error. The second case is OK to silently ignore; however, the existing code leaked the buffer returned by read_sha1_file. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/tag.c')
-rw-r--r--builtin/tag.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/tag.c b/builtin/tag.c
index 391160c..1e27f5c 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -93,8 +93,12 @@ static void show_tag_lines(const unsigned char *sha1, int lines)
size_t len;
buf = read_sha1_file(sha1, &type, &size);
- if (!buf || !size)
+ if (!buf)
+ die_errno("unable to read object %s", sha1_to_hex(sha1));
+ if (!size) {
+ free(buf);
return;
+ }
/* skip header */
sp = strstr(buf, "\n\n");