Re: [PATCH] Segmentation fault on non-commit objects.
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 30, 2019, 02:44 UTC
- Message-ID
- <xmqqbltz3qbc.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20191029140621.GC2843@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 12 quoted lines
> This is definitely a strict improvement over the current behavior > (though I agree with Dscho's comments on the error message). A few > further thoughts: > > - we'll have successfully completed the rest of the clone at this > point. Should we leave the objects and refs in place to allow the > user to fix it up, as we do when "git checkout" fails? > > We'd have to leave _something_ in HEAD for it to be a valid repo. I > guess just "refs/heads/master" would be fine, or perhaps we could > fall back to whatever the other side had in their HEAD (i.e., > pretending that "-b" wasn't specified).
Do we know for sure that the object at HEAD on the other side is a commit, or do we need to prepare for a case where it is not? I suspect it is the latter. HEAD needs to exist and point at a ref that is in refs/heads/ hierarchy, and the ref can even be unborn, so falling back on 'master' sounds like a good position.
Show 6 quoted lines
> - there's a related case just above the lines you touched: what > happens if the other side feeds us a non-commit in their > refs/heads/? That shouldn't happen (i.e., their repo is broken), but > should we be protecting ourselves on the receiving side more? > > Likewise in "else" below just above your lines.
Both are good points.
Thanks, all.