From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Git Mailing List" <git@vger.kernel.org>
Subject: Re: BUG: Segfault on "git pull" on "bad object HEAD"
Date: Wed, 11 Jul 2018 10:09:03 -0700 [thread overview]
Message-ID: <xmqqo9fd3djk.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20180711133402.GD23835@sigill.intra.peff.net> (Jeff King's message of "Wed, 11 Jul 2018 09:34:02 -0400")
Jeff King <peff@peff.net> writes:
> 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.
next prev parent reply other threads:[~2018-07-11 17:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-11 11:00 BUG: Segfault on "git pull" on "bad object HEAD" Ævar Arnfjörð Bjarmason
2018-07-11 13:34 ` Jeff King
2018-07-11 14:14 ` [PATCH] has_uncommitted_changes(): fall back to empty tree Jeff King
2018-07-11 14:41 ` Ævar Arnfjörð Bjarmason
2018-07-11 15:00 ` Jeff King
2018-07-11 17:09 ` Junio C Hamano [this message]
2018-07-11 15:56 ` BUG: Segfault on "git pull" on "bad object HEAD" Duy Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqo9fd3djk.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).