Subject: Re: git archive

From: kenneth johansson <[email-masked]>
Date: Wed, 22 Oct 2008 18:45:30 +0000 (UTC)

On Wed, 22 Oct 2008 09:08:29 -0400, Deskin Miller wrote:

> On Wed, Oct 22, 2008 at 08:42:01AM +0000, kenneth johansson wrote:
>> I was going to make a tar of the latest stable linux kernel. Done it
>> before but now I got a strange problem.
>> 
>> >git archive --format=tar v2.6.27.2
>> fatal: Not a valid object name
> 
> I had the same thing happen to me, while trying to make an archive of
> Git. Were you perchance working in a bare repository, as I was?  I spent
> some time looking at it and I think git archive sets up the environment
> in the wrong order, though of course I never finished a patch so I'm
> going from memory:

Yes it was a bare repository.

> 
> After looking at the code again, I think the issue is that git_config is
> called in builtin-archive.c:cmd_archive before setup_git_directory is
> called in archive.c:write_archive.  The former ends up setting GIT_DIR
> to be '.git' even if you're in a bare repository.  My coding skills
> weren't up to fixing it easily; moving setup_git_directory before
> git_config in builtin-archive caused last test of t5000 to fail:
> GIT_DIR=some/nonexistent/path git archive --list should still display
> the archive formats.

if I do
GIT_DIR=. git  archive --format=tar v2.6.27.2

it does work so it looks like you are on the right track.