3

Say I have a repo with these files:

aaa.txt
f1/bbb.txt
f1/f2/ccc.txt

If my CWD is the top of working tree, I get this result:

$ git ls-tree -r --name-only $(git write-tree)
aaa.txt
f1/bbb.txt
f1/f2/ccc.txt

$ git ls-tree -rd --name-only $(git write-tree)
f1
f1/f2

If my CWD is in the f1 directory, I get this result:

$ git ls-tree -r --name-only $(git write-tree)
bbb.txt
f2/ccc.txt

$ git ls-tree -rd --name-only $(git write-tree)

I expect git ls-tree -rd --name-only $(git write-tree) to return f2. However the result is empty. Am I doing something wrong?

Danny Lin
  • 2,050
  • 1
  • 20
  • 34

1 Answers1

0

That might be an issue linked to the old msysgit 32bits Git For Windows 1.9.5, where I did reproduce the same issue.

I just tested it in a git bash session using the new msys2 64bits Git For Windows 2.3.5, and it works perfectly.

VonC@voncvb MINGW64 /c/Users/VonC/prog/go/src/github.com/VonC/senvgo (master)
$ git ls-tree -rd --name-only $(git write-tree)
.deps
.deps/godbg
configs
envs
installer
paths
paths/7z
prgs

VonC@voncvb MINGW64 /c/Users/VonC/prog/go/src/github.com/VonC/senvgo (master)
$ cd paths/

VonC@voncvb MINGW64 /c/Users/VonC/prog/go/src/github.com/VonC/senvgo/paths (master)
$ git ls-tree -rd --name-only $(git write-tree)
./
7z
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • You are right. It seems to work in a later version of git. However it seems to output directories in the whole repo instead of the childs of CWD, and there are extra `./` when CWD is `f1` and `../` and `./` when CWD is `f1/f2`. Is there a way to fix this? – Danny Lin Apr 22 '15 at 06:44
  • @DannyLin I am sorry I missed your comment. I didn't see a way to change the output (the `-r` option does ls the tree recursively). Did you manage to get the expected output? – VonC May 02 '15 at 04:17
  • No. I just wonder whether it's a bug or I'm doing something wrong. It seems that I have to filter starting ./ and ../ out if I'm going to make it work currently. – Danny Lin May 02 '15 at 06:03