Re: [PATCH] pull: do not segfault when HEAD refers to missing object file
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Mar 6, 2017, 06:52 UTC
- Message-ID
- <6726b36d-6f50-d258-12e3-8b7b56159631@kdbg.org>
- In-Reply-To
- <20170306035152.c7bh5jiqrfncyudl@sigill.intra.peff.net>
Am 06.03.2017 um 04:51 schrieb Jeff King:
Show 6 quoted lines
> On Sun, Mar 05, 2017 at 11:52:22PM +0000, brian m. carlson wrote: > >> On Mon, Mar 06, 2017 at 12:42:22AM +0100, André Laszlo wrote: >>> +test_expect_success 'git pull --rebase with corrupt HEAD does not segfault' ' >>> + mkdir corrupted && >>> + (cd corrupted &&
We usally indent this like so:
( cd corrupted && echo one >file && git add file && ... ) &&
Show 17 quoted lines
>>> + git init &&
>>> + echo one >file && git add file &&
>>> + git commit -m one &&
>>> + REV=$(git rev-parse HEAD) &&
>>> + rm -f .git/objects/${REV:0:2}/${REV:2} &&
>>
>> I think this is a bashism. On dash, I get the following:
>>
>> genre ok % dash -c 'foo=abcdefg; echo ${foo:0:2}; echo ${foo:2}'
>> dash: 1: Bad substitution
>
> Yeah, it is. You can do it easily with 'sed', of course, but if you want
> to avoid the extra process and do it in pure shell, it's more like:
>
> last38=${REV#??}
> first2=${REV%$last38}
> rm -f .git/objects/$first2/$last38Is it "HEAD points to non-existent object" or ".git/HEAD contains junk"? In both cases there are simpler solutions than to remove an object. For example, `echo "$_x40" >.git/HEAD` or `echo "this is junk" >.git/HEAD`?
-- Hannes