attr.c doesn't honor --work-tree option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

It seems that code in attr.c does not honor the current work tree path
(set by e.g. --work-tree ...) and simply always assumes CWD. When the
current dir is not in the work tree, git will attempt to find
.gitattributes under ./ instead of under the correct work tree.

Here's a repro with -DDEBUG_ATTR=1 and a printf() in read_attr_from_file():

$ cd /tmp/
$ mkdir -p attr-test/repo
$ cd attr-test/repo
$ git init
Initialized empty Git repository in /tmp/attr-test/repo/.git/
$ echo 'dir/* filter=foo' >.gitattributes
$

Inside the working tree, it works:

$ ~/src/git.git/git check-attr -a dir/file
read_attr_from_file: /home/lasse/etc/gitattributes
read_attr_from_file: /home/lasse/.config/git/attributes
read_attr_from_file: .gitattributes
push:
read_attr_from_file: .git/info/attributes
read_attr_from_file: dir/.gitattributes
push: dir
fill: filter => foo (dir/*)
dir/file: filter: foo
$

Outside, it fails to find the .gitattributes file:

$ cd ..
$ ~/src/git.git/git --work-tree /tmp/attr-test/repo --git-dir
/tmp/attr-test/repo/.git check-attr -a dir/file
read_attr_from_file: /home/lasse/etc/gitattributes
read_attr_from_file: /home/lasse/.config/git/attributes
read_attr_from_file: .gitattributes
push:
read_attr_from_file: /tmp/attr-test/repo/.git/info/attributes
read_attr_from_file: dir/.gitattributes
push: dir
$

This is with the latest rev on master:

$ ~/src/git.git/git --version
git version 1.8.5.2.192.g7794a68.dirty
$

It (sort of) works with a committed .gitattributes file because git
will find it in the index, but that will still yield incorrect results
if the .gitattributes file happens to be dirty.

Looking at the code, I'm not really sure if this can be fixed in
read_attr_from_file() by resolving relative paths against
get_git_work_tree(). I doubt it's that simple though...

Thoughts?

/Lasse
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]