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.