git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: BUG: Segfault on "git pull" on "bad object HEAD"

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 11, 2018, 17:09 UTC
Message-ID
<xmqqo9fd3djk.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180711133402.GD23835@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 27 quoted lines
> 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.
Previous: Jeff KingNext: Duy Nguyen
Message 6 of 7 in “BUG: Segfault on "git pull" on "bad object HEAD"”
  1. Ævar Arnfjörð BjarmasonJul 11, 2018
  2. Jeff KingJul 11, 2018
  3. has_uncommitted_changes(): fall back to empty treeJeff King, Jul 11, 2018
  4. Ævar Arnfjörð BjarmasonJul 11, 2018
  5. Jeff KingJul 11, 2018
  6. Junio C HamanoJul 11, 2018
  7. Duy NguyenJul 11, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.