Re: BUG: Segfault on "git pull" on "bad object HEAD"
From: Junio C Hamano <hidden>
Date: 2018-07-11 17:09:08
Jeff King [off-list ref] writes:
quoted hunk
So I feel like the right answer here is probably this:diff --git a/wt-status.c b/wt-status.c index d1c05145a4..5fcaa3d0f8 100644 --- a/wt-status.c +++ b/wt-status.c@@ -2340,7 +2340,16 @@ int has_uncommitted_changes(int ignore_submodules) if (ignore_submodules) rev_info.diffopt.flags.ignore_submodules = 1; rev_info.diffopt.flags.quick = 1; + add_head_to_pending(&rev_info); + if (!rev_info.pending.nr) { + /* + * We have no head (or it's corrupt), but the index is not + * unborn; declare it as uncommitted changes. + */ + return 1; + } + diff_setup_done(&rev_info.diffopt); result = run_diff_index(&rev_info, 1); return diff_result_code(&rev_info.diffopt, result);That does quietly paper over the corruption, but it does the conservative thing, and a follow-up "git status" would yield "bad object: HEAD".
Sounds quite sensible.