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

Re: [PATCH] branch_get_push: do not segfault when HEAD is detached

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 9, 2017, 10:32 UTC
Message-ID
<xmqqy3ykwmlb.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170107013126.4ub726mf73y36of3@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 11 quoted lines
> On Fri, Jan 06, 2017 at 08:19:53PM -0500, Kyle Meyer wrote:
>
>> > The other option is just "git checkout --detach", which is also used in
>> > the test suite. I tend to prefer it because it's a little more obvious
>> > to a reader.
>> 
>> True, that does seem clearer.  Seems I should've waited a bit before
>> sending out v2.
>
> I think it's OK either way. Junio can also mark it up while applying,
> too, if he has a preference.

I prefer <commit>^0 in scripts, simply because it is shorter, works with any version of Git that knows how to detach, even the ones before --detach was introduced. I offhand do not recall which between <commit>^0 and <commit>^{} came earlier, but in practice I saw nobody write the latter, so Dscho's suggestion is definitely an improvement.

I do also care about "git checkout --detach" to keep working correctly, but as long as we have dedicated tests to ensure that, we'd be fine. In the case of the test being discussed, we assume either should work correctly and the point of the test is not about ensuring that <commit>^0 or --detach works, so either is OK.

Anyway, thanks for a patch and a review.
Previous: Jeff KingNext: Kyle Meyer
Message 8 of 9 in “branch_get_push: do not segfault when HEAD is detached”
  1. branch_get_push: do not segfault when HEAD is detachedKyle Meyer, Jan 6, 2017
  2. Jeff KingJan 6, 2017
  3. Johannes SchindelinJan 6, 2017
  4. Kyle MeyerJan 7, 2017
  5. Jeff KingJan 7, 2017
  6. Kyle MeyerJan 7, 2017
  7. Jeff KingJan 7, 2017
  8. Junio C HamanoJan 9, 2017
  9. branch_get_push: do not segfault when HEAD is detachedKyle Meyer, Jan 7, 2017

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.