Skip to content

Commit

Permalink
tag: die when listing missing or corrupt objects
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Feb 6, 2012
1 parent ca51699 commit fb630e0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion builtin/tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit fb630e0

Please sign in to comment.