# git-{diff,ls}-files from a subdirectory fails ...

4 messages from 2007-10-24 to 2007-10-24. Participants: Karl Hasselström, Johannes Schindelin.
Thread: https://gitlist.dev/t/10444

## Karl Hasselström, 2007-10-24 01:20

Subject: git-{diff,ls}-files from a subdirectory fails ...
Message-ID: <20071024012038.GA31326@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20071024012038.GA31326%40diana.vm.bytemark.co.uk

```
... when GIT_DIR is specified.

I have a repository at ~/stgit-lib. With cwd at the top of the tree,
things work as expected when I set all those fancy envoronment
variables:

  kha@yoghurt:~/stgit-lib> git-diff-files --name-only
  stgit/utillib.py

  kha@yoghurt:~/stgit-lib> GIT_DIR=/home/kha/stgit-lib/.git GIT_INDEX_FILE=/home/kha/stgit-lib/.git/index GIT_WORK_TREE=/home/kha/stgit-lib git-diff-files --name-only
  stgit/utillib.py

However, it doen't seem to work from a subdirectory:

  kha@yoghurt:~/stgit-lib/stgit> git-diff-files --name-only
  stgit/utillib.py

  kha@yoghurt:~/stgit-lib/stgit> GIT_DIR=/home/kha/stgit-lib/.git GIT_INDEX_FILE=/home/kha/stgit-lib/.git/index GIT_WORK_TREE=/home/kha/stgit-lib git-diff-files --name-only | wc
      170     170    3560

Instead of just the one changed file, I get a list of what looks like
all the files in the project, suggesting that maybe git assumes I'm at
the root of the worktree when I'm not.

git-ls-files seems to behave the same way. Bug or user error?

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```

## Johannes Schindelin, 2007-10-24 10:06

Subject: Re: git-{diff,ls}-files from a subdirectory fails ...
Message-ID: <Pine.LNX.4.64.0710241104560.25221@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0710241104560.25221%40racer.site
In-Reply-To: <20071024012038.GA31326@diana.vm.bytemark.co.uk>

```
Hi,

On Wed, 24 Oct 2007, Karl Hasselstr?m wrote:

> ... when GIT_DIR is specified.
> 
> I have a repository at ~/stgit-lib. With cwd at the top of the tree,
> things work as expected when I set all those fancy envoronment
> variables:
> 
>   kha@yoghurt:~/stgit-lib> git-diff-files --name-only
>   stgit/utillib.py
> 
>   kha@yoghurt:~/stgit-lib> GIT_DIR=/home/kha/stgit-lib/.git GIT_INDEX_FILE=/home/kha/stgit-lib/.git/index GIT_WORK_TREE=/home/kha/stgit-lib git-diff-files --name-only
>   stgit/utillib.py
> 
> However, it doen't seem to work from a subdirectory:
> 
>   kha@yoghurt:~/stgit-lib/stgit> git-diff-files --name-only
>   stgit/utillib.py
> 
>   kha@yoghurt:~/stgit-lib/stgit> GIT_DIR=/home/kha/stgit-lib/.git GIT_INDEX_FILE=/home/kha/stgit-lib/.git/index GIT_WORK_TREE=/home/kha/stgit-lib git-diff-files --name-only | wc
>       170     170    3560

>From looking at it (very) briefly, it seems that you encountered the same 
bug that was fixed in

dd5c8af176bb935a0b01a7dc2d5e022565c3aac3(Fix setup_git_directory_gently() 
with relative GIT_DIR & GIT_WORK_TREE).

IOW if you run git version v1.5.3.4-14-gdd5c8af or newer, you should not 
experience this.

Hth,
Dscho

```

## Karl Hasselström, 2007-10-24 10:40

Subject: Re: git-{diff,ls}-files from a subdirectory fails ...
Message-ID: <20071024104055.GB3908@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20071024104055.GB3908%40diana.vm.bytemark.co.uk
In-Reply-To: <Pine.LNX.4.64.0710241104560.25221@racer.site>

```
On 2007-10-24 11:06:43 +0100, Johannes Schindelin wrote:

> On Wed, 24 Oct 2007, Karl Hasselström wrote:
>
> > However, it doen't seem to work from a subdirectory:
> >
> >   kha@yoghurt:~/stgit-lib/stgit> git-diff-files --name-only
> >   stgit/utillib.py
> >
> >   kha@yoghurt:~/stgit-lib/stgit> GIT_DIR=/home/kha/stgit-lib/.git GIT_INDEX_FILE=/home/kha/stgit-lib/.git/index GIT_WORK_TREE=/home/kha/stgit-lib git-diff-files --name-only | wc
> >       170     170    3560
>
> From looking at it (very) briefly, it seems that you encountered the
> same bug that was fixed in
>
> dd5c8af176bb935a0b01a7dc2d5e022565c3aac3(Fix setup_git_directory_gently()
> with relative GIT_DIR & GIT_WORK_TREE).
>
> IOW if you run git version v1.5.3.4-14-gdd5c8af or newer, you should
> not experience this.

Thanks for the pointer; that looks like it might indeed fix this bug.
Will hopefully have time to verify later today.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```

## Karl Hasselström, 2007-10-24 11:26

Subject: Re: git-{diff,ls}-files from a subdirectory fails ...
Message-ID: <20071024112626.GA6459@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20071024112626.GA6459%40diana.vm.bytemark.co.uk
In-Reply-To: <20071024104055.GB3908@diana.vm.bytemark.co.uk>

```
On 2007-10-24 12:40:55 +0200, Karl Hasselström wrote:

> On 2007-10-24 11:06:43 +0100, Johannes Schindelin wrote:
>
> > IOW if you run git version v1.5.3.4-14-gdd5c8af or newer, you
> > should not experience this.
>
> Thanks for the pointer; that looks like it might indeed fix this
> bug. Will hopefully have time to verify later today.

It works! Very timely bugfix ...

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```
