Re: attr.c doesn't honor --work-tree option
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 6, 2014, 17:54 UTC
- Message-ID
- <xmqqvbwsyvn8.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <CAB7pA0_2kLJmRZb8Z_9+xOcrbwMZLgnZwC5f7etbE4OuJ1wgmA@mail.gmail.com>
Lasse Makholm <lasse.makholm@gmail.com> writes:
Show 13 quoted lines
> 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
Does check-ignore misbehave the same way?
I suspect that is this because check-attr is not a command that requires a working tree. The command was written primarily as a debugging aid that can be used anywhere as long as you have a repository to read strings from either its standard input or its arguments, and gives them directly to check_attr(), but it does so without first going to the top of the real working tree like check-ignore does.
Forcing it to go to the top of the working tree (see the attached one-liner, but note that I didn't test it) may give you want you want.
git.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/git.c b/git.c index 7cf2953..314ec9f 100644 --- a/git.c +++ b/git.c @@ -342,7 +342,7 @@ static struct cmd_struct commands[] = { { "branch", cmd_branch, RUN_SETUP }, { "bundle", cmd_bundle, RUN_SETUP_GENTLY }, { "cat-file", cmd_cat_file, RUN_SETUP }, - { "check-attr", cmd_check_attr, RUN_SETUP }, + { "check-attr", cmd_check_attr, RUN_SETUP | NEED_WORK_TREE }, { "check-ignore", cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE }, { "check-mailmap", cmd_check_mailmap, RUN_SETUP }, { "check-ref-format", cmd_check_ref_format },