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

Re: [PATCH] Segmentation Fault on non-commit --branch clone

From
Davide Berardi <berardi.dav@gmail.com>
Date
Nov 3, 2019, 18:16 UTC
Message-ID
<20191103181657.GA89185@carpenter.lan>
In-Reply-To
<xmqqh83m1t3c.fsf@gitster-ct.c.googlers.com>
On Sat, Nov 02, 2019 at 07:16:23PM +0900, Junio C Hamano wrote:
Show 15 quoted lines
>Jeff King <peff@peff.net> writes:
>
>> I don't know how often this would actually help users, though. It _is_ a
>> pretty rare situation to ask for a non-commit. So maybe it's all
>> over-engineering, and we should start with just die(). If somebody comes
>> along later and wants to enhance it, it should be pretty
>> straightforward.
>
>I like that; after update_head() finishes, there are a few clean-up
>things that the caller wants to do besides a checkout() call, but if
>we make update_head() return a failure, perhaps the caller side
>change would be as small as the attached patch.  That would go nicely
>with the "make the result just barely usable" approach of leaving an
>unborn master branch I suggested in a separate message, I would think.
>

Thank you all for your precious comments, I've tried to implement your suggestions and I've sent the patch here.

The problem with the proposed approach was that the code was incompatible with some tests (specifically the tests which specifies an empty .git directory would fail and fallback to the unborn master branch).

The lookup commit have two error-paths:
1. the commit cannot be found;
2. the commit is found and cannot be casted to a commit (whoops!).

so, I've returned the second condition using an auxiliary variable and declaring a new lookup_commit function keeping compatibility with the old one.

I'm sorry for my errors but I'm far for an expert of git internals, thank you (all) for your time and kindness.

ciao, D.

Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 14 in “Segmentation Fault on non-commit --branch clone”
  1. Segmentation Fault on non-commit --branch cloneDavide Berardi, Nov 1, 2019
  2. Johannes SchindelinNov 1, 2019
  3. Jeff KingNov 1, 2019
  4. Junio C HamanoNov 2, 2019
  5. Davide BerardiNov 3, 2019
  6. Junio C HamanoNov 4, 2019
  7. Junio C HamanoNov 2, 2019
  8. Jeff KingNov 1, 2019
  9. Junio C HamanoNov 2, 2019
  10. clone: Don't segfault on -b specifing a non-commitDavide Berardi, Nov 3, 2019
  11. Jeff KingNov 5, 2019
  12. Junio C HamanoNov 6, 2019
  13. Jeff KingNov 6, 2019
  14. Junio C HamanoNov 6, 2019

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.