Subject: Re: git-archive and unwanted .gitattributes

From: Jakub Narebski <[email-masked]>
Date: Sat, 07 Jun 2008 08:47:35 -0700 (PDT)

"Nguyen Thai Ngoc Duy" <[email-masked]> writes:

> Currently attr.c will read .gitattributes on disk no matter there is a
> real worktree or not. 

Currently .gitattributes are read _only_ from the work tree.
There isn't even infrastructure to read .gitattributes for commit
(from a tree); git-check-attr, and I guess also internal git API,
deals only with in-tree .gitattribute file.

> This can lead to strange behavior. For example when I do
> 
> mkdir a && cd a
> git init
> echo '$Format:%s$' > a
> git add a && git commit -m initial
> cd ..
> echo 'a export-subst' > .gitattributes # let's assume this is an accident.
> git --git-dir=a/.git archive --format=tar HEAD|tar xO a
> 
> I expect it to show '$Format:%s$', not "initial". git-archive should
> not bother reading that .gitattributes. I thought an
> is_inside_work_tree() check would be enough. Unfortunately, setting
> --git-dir will automatically set worktree too. Any ideas?

And it doesn't work at all for bare repositories.

I guess that might have been caused by the fact, that .gitattributes
are similar to .gitignore file; but in this they are different.  Of
course there is chicken-and-egg problem with attributes affecting
checkout...

-- 
Jakub Narebski
Poland
ShadeHawk on #git