Skip to content

Commit

Permalink
show-branch: Be nicer when running in a corrupt repository.
Browse files Browse the repository at this point in the history
We may end up trying to print a commit we do not actually have but we
know about its existence only because another commit we do have refers
to it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
(cherry picked from b204feab9371040982d2c60611925e7693106c84 commit)
  • Loading branch information
Junio C Hamano committed Sep 20, 2005
1 parent 1f961c1 commit 0a2ba73
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions show-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,11 @@ static void show_one_commit(struct commit *commit)
{
char pretty[128], *cp;
struct commit_name *name = commit->object.util;
pretty_print_commit(CMIT_FMT_ONELINE, commit->buffer, ~0,
pretty, sizeof(pretty));
if (commit->object.parsed)
pretty_print_commit(CMIT_FMT_ONELINE, commit->buffer, ~0,
pretty, sizeof(pretty));
else
strcpy(pretty, "(unavailable)");
if (!strncmp(pretty, "[PATCH] ", 8))
cp = pretty + 8;
else
Expand Down

0 comments on commit 0a2ba73

Please sign in to comment.