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

Re: [PATCH] checkout: fix BUG() case in 9081a421a6

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 21, 2022, 21:19 UTC
Message-ID
<xmqqczkkg51h.fsf@gitster.g>
In-Reply-To
<220121.86iludl4d9.gmgdl@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 8 quoted lines
>> So, unless I hear more convincing arguments (and Todd's example or
>> anything similar that makes "git commit" from that state update a
>> ref outside local branches is *not*), I am hesitant to call the new
>> behaviour and 9081a421a6d a regression.
>
> Well, the user is doing odd things with git, but we should reserve BUG()
> for things that aren't rechable. Any time a user is able to arrange our
> tooling in such a way as to call BUG() is a ... bug.
Yes, I concur.
Show 14 quoted lines
>> What did the code before that BUG() do when faced with this nonsense
>> configuration?  If forbidding outright broke a sensible workflow
>> that happened to have been "working", I am OK to demote it to
>> warning() and restore the previous behaviour temporarily, whatever
>> it was (I think it was just old_branch_info.name was left unset
>> because we were not on local branch, but I don't know if the missing
>> .name was making any irrecoverable damage).  But the longer term
>> direction should be that we treat the "update HEAD ends up updating
>> some ref outside refs/heads/" a longstanding bug that needs to be
>> fixed.
>
> The behavior with my patch here is exactly the same as before. I.e. it
> was rather straightforward, the xstrdup() is new, but before we'd just
> take the un-skipped string that didn't start with refs/heads/ as-is.

OK, that might have done a wrong thing (instead of dying) for a strange settings like that, but the change was never about tightening and detecting such a strangeness but only about plugging leaks, so reverting that narrow part of the patch is the right thing to do.

> I agree that it's better to look at this more deeply, but given the rc2
> being out, and this surely being something we want in the final I'd
> think we'd want to keep this patch as-is.

Yes, except for the update in the test. I do not think we want to promise what should happen to the _values_ of these refs after the operation at all. If it only says "checkout should not exit with non-zero status", I would be OK. Promising anything more than that, I do not think it is a good idea.

For now, I plan to do the "revert the check-and-BUG and nothing else" change.

Thanks.
Previous: Todd ZullingerNext: Todd Zullinger
Message 9 of 16 in “[BUG] builtin/checkout.c:1098: should be able to skip past 'refs/heads/'”
  1. Todd ZullingerJan 20, 2022
  2. Todd ZullingerJan 20, 2022
  3. checkout: fix BUG() case in 9081a421a6Ævar Arnfjörð Bjarmason, Jan 20, 2022
  4. Junio C HamanoJan 20, 2022
  5. Junio C HamanoJan 20, 2022
  6. Ævar Arnfjörð BjarmasonJan 21, 2022
  7. Petr ŠplíchalJan 21, 2022
  8. Todd ZullingerJan 21, 2022
  9. Junio C HamanoJan 21, 2022
  10. Todd ZullingerJan 20, 2022
  11. Junio C HamanoJan 22, 2022
  12. Junio C HamanoJan 22, 2022
  13. checkout: avoid BUG() when hitting a broken repositoryJunio C Hamano, Jan 22, 2022
  14. Johannes SixtJan 22, 2022
  15. Ævar Arnfjörð BjarmasonJan 22, 2022
  16. Johannes SchindelinJan 23, 2022

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.