3

bash: GNU bash, version 4.3.42(4)-release (x86_64-pc-msys)
OS: Windows7
git: git version 2.6.4.windows.1

Without command substitution, directly executing git commands would return correct answers.

$ git write-tree
76cb4719e27c7d77ef396992b3ba90cd98d22fcd

But when I execute some git commands with command substitution, it would return nothing.

$ echo "`git write-tree`"

$ echo "$(git write-tree)"

But the most strange thing is: Only some of git commmands occur this problem, for example: git write-tree, git rev-parse, git var. And other git commands, such as git log, run well.

And some environment is exactly as same as mine, OS, bash and git. But everything works fine.
As a result, I wanna konw whether there's something I need to configure. This thing really confuse me.

styshoo
  • 563
  • 4
  • 9
  • git-write-tree document says "Conceptually, git write-tree sync()s the current index contents into a set of tree files. In order to have that match what is actually in your directory right now, you need to have done a git update-index phase before you did the git write-tree." try giving git update-index and git write-tree – skr Jul 19 '17 at 08:22

1 Answers1

0

That must have been fixed in more recent version of Git for Windows.
Here is what I see with Git 2.18, in a bash session:

vonc@vonca:/mnt/d/git/tests/aa$ echo $(git write-tree)
4b825dc642cb6eb9a060e54bf8d69288fbee4904

vonc@vonca:/mnt/d/git/tests/aa$ echo "$(git write-tree)"
4b825dc642cb6eb9a060e54bf8d69288fbee4904

If the issue is still random, try making the same test using a CMD session with a simplified PATH, and launching the bash from said session.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250