Re: Can't build first git commit
- Date: Thu, 7 Mar 2019 14:41:47 -0500
- From: Jeff King <peff@xxxxxxxx>
- Subject: Re: Can't build first git commit
[+cc git@vger; let's keep this on the list; I'm not sure there's a lot
to be learned from fiddling with this old version, but if we're going
to do it, let's at least record our attempts for posterity]
On Thu, Mar 07, 2019 at 08:04:55PM +0100, Fabio Aiuto wrote:
> I made a directory "trial" and inside it I ran init-db (that's the
> grand-father of git init) inside that directory. Then I created a file
> this way:
> echo 'helloooo!' >file.txt
> then then executed update-cache file.txt (thinking that's the ancestor
> of git add), but that doesn't work and it returns with a segmentation
> fault, due to the nullity of the header. But in this first commit how
> do I add a file in the cache? What's the right way to build up a
> repository from scratch with commit e83c5163316f?
Hmm. I tried that, too, and got a segfault. Then I tried it again a few
minutes later, and it worked.
One thing that seems to provoke it consistently is having a zero-length
index file (because that causes mmap to return NULL, and the code does
not check for that case). Try this:
# This works.
echo content >file
# This segfaults
# And this works again
I'm not sure why it would ever fail without that explicit empty-file
write. Perhaps there's some code path that writes out an empty index
file, and we inadvertently triggered it.
If you're going to play with such an antique commit, you have to expect
that things won't necessarily work, and be ready to poke around in the