git check-attr in bare repositories
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Mar 29, 2010, 23:15 UTC
- Message-ID
- <20100329231501.GA28194@progeny.tock>
- In-Reply-To
- <19376.53419.640007.930897@winooski.ccs.neu.edu>
Eli Barzilay wrote:
> On Mar 29, Eli Barzilay wrote: >> On Mar 27, Jonathan Nieder wrote:
[in a bare repository]
>>> GIT_INDEX=tmp-index git check-attr "$@" &&
[...]
>> I tried that, but it doesn't work. (I used GIT_INDEX_FILE.)
Yes, not sure how I confused myself.
git explicitly guards against that in attr.c.
/*
* Read from parent directories and push them down
*/
if (!is_bare_repository() || direction == GIT_ATTR_INDEX) {That check comes from v1.5.6-rc3~9^2 (Ignore .gitattributes in bare repositories, 2008-06-08). This is consistent with how bare repositories generally work: they are guarded against use with a populated index, since what filesystem tree would that index track?
To support your use case, it would be nice for check-attr to learn a --direction option. Maybe it would be safe to let check-attr read from the index in bare repositories by default anyway, since the index is usually missing anyway.
Properly supporting general work in a bare repository would require a larger effort. Maybe:
- Teach code that checks is_bare_repository() to check get_git_work_tree() == NULL or similar instead.
- Make the work_tree and git_dir variables the responsibility of the setup code.
- If the user sets GIT_INDEX_FILE or GIT_WORK_TREE, let the setup code respect that wish even if core.bare is set.
Thoughts? Jonathan