@matheusbsbs / matheus-bagliano / commits / 0a2ba73860
Fork 0

show-branch: Be nicer when running in a corrupt repository.

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)

Junio C Hamano committed Sep 19, 2005 at 01:12 UTC 0a2ba73860211efec479396c33ba381056715be5
1 file changed +5 -2
show-branch.c
+5 -2
@@ -196,8 +196,11 @@ static void show_one_commit(struct commit *commit)
196 {
197 char pretty[128], *cp;
198 struct commit_name *name = commit->object.util;
199 - pretty_print_commit(CMIT_FMT_ONELINE, commit->buffer, ~0,
200 - pretty, sizeof(pretty));
199 + if (commit->object.parsed)
200 + pretty_print_commit(CMIT_FMT_ONELINE, commit->buffer, ~0,
201 + pretty, sizeof(pretty));
202 + else
203 + strcpy(pretty, "(unavailable)");
204 if (!strncmp(pretty, "[PATCH] ", 8))
205 cp = pretty + 8;
206 else