Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git difftool: cannot create directory at '' #1124

Closed
1 task done
Radrik5 opened this issue Apr 4, 2017 · 12 comments
Closed
1 task done

git difftool: cannot create directory at '' #1124

Radrik5 opened this issue Apr 4, 2017 · 12 comments
Assignees
Milestone

Comments

@Radrik5
Copy link

Radrik5 commented Apr 4, 2017

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.12.2.windows.1
built from commit: 212247dd6345c820deeae61fcdf2f10cea10525a
sizeof-long: 4
machine: x86_64
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?

Windows 7 64 bit

$ cmd.exe /c ver

Microsoft Windows [Version 6.1.7601]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Path Option: Cmd
SSH Option: OpenSSH
CURL Option: WinSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

It doesn't depend on environment (see below).

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Git Bash

# Works well:
$ git difftool --tool=beyondcompare3dd --dir-diff HEAD^ HEAD^^

# Gives the error:
$ git difftool --tool=beyondcompare3dd --dir-diff HEAD^^ HEAD^

# Also works well:
$ git difftool --tool=beyondcompare3dd --dir-diff HEAD^^ HEAD

The problem is reproduced on this particular repo with this particular commits. Running the commands on another repo correctly opens Beyond Compare. Using commit hashes instead of HEAD in this repo gives the same error. Running the command with other commits works fine. Unfortunately, the repo is private, so I cannot provide MCVE.

  • What did you expect to occur after running these commands?
$ GIT_TRACE=1 git difftool --tool=beyondcompare3dd --dir-diff HEAD^ HEAD^^
17:57:34.092566 git.c:371               trace: built-in: git 'difftool' '--tool=beyondcompare3dd' '--dir-diff' 'HEAD^' 'HEAD^^'
17:57:34.094566 run-command.c:369       trace: run_command: 'diff' '--raw' '--no-abbrev' '-z' 'HEAD^' 'HEAD^^'
17:57:34.106567 git.c:371               trace: built-in: git 'diff' '--raw' '--no-abbrev' '-z' 'HEAD^' 'HEAD^^'
17:57:34.186575 run-command.c:369       trace: run_command: 'difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a12540/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a12540/right/'
17:57:34.196576 git.c:596               trace: exec: 'git-difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a12540/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a12540/right/'
17:57:34.197577 run-command.c:369       trace: run_command: 'git-difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a12540/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a12540/right/'
17:57:34.264583 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'
17:57:34.286585 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.path'
17:57:34.304587 git.c:371               trace: built-in: git 'config' 'mergetool.beyondcompare3dd.path'
17:57:34.331590 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'
17:57:34.354592 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'
  • What actually happened instead?
$ GIT_TRACE=1 git difftool --tool=beyondcompare3dd --dir-diff HEAD^^ HEAD^
17:58:35.287685 git.c:371               trace: built-in: git 'difftool' '--tool=beyondcompare3dd' '--dir-diff' 'HEAD^^' 'HEAD^'
17:58:35.288685 run-command.c:369       trace: run_command: 'diff' '--raw' '--no-abbrev' '-z' 'HEAD^^' 'HEAD^'
17:58:35.297686 git.c:371               trace: built-in: git 'diff' '--raw' '--no-abbrev' '-z' 'HEAD^^' 'HEAD^'
fatal: cannot create directory at '': No such file or directory
  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

The problem occurs with a specific repository but I cannot share it.

Is there something like GIT_TRACE=1 that can help to understand what causes the error?

@Radrik5
Copy link
Author

Radrik5 commented Apr 4, 2017

Depends on the current commit (HEAD):

# Detached HEAD at commit next to the buggy commit
client $ git checkout HEAD@{0}
HEAD is now at df117c7fe4...

client $ GIT_TRACE=1 git difftool --tool=beyondcompare3dd --dir-diff HEAD^^ HEAD^
18:19:55.688712 git.c:371               trace: built-in: git 'difftool' '--tool=beyondcompare3dd' '--dir-diff' 'HEAD^^' 'HEAD^'
18:19:55.689712 run-command.c:369       trace: run_command: 'diff' '--raw' '--no-abbrev' '-z' 'HEAD^^' 'HEAD^'
18:19:55.703714 git.c:371               trace: built-in: git 'diff' '--raw' '--no-abbrev' '-z' 'HEAD^^' 'HEAD^'
fatal: cannot create directory at '': No such file or directory

# Move HEAD to the buggy commit
client $ git checkout HEAD^
HEAD is now at efd66171d2...

client $ GIT_TRACE=1 git difftool --tool=beyondcompare3dd --dir-diff HEAD^ HEAD
18:20:08.557999 git.c:371               trace: built-in: git 'difftool' '--tool=beyondcompare3dd' '--dir-diff' 'HEAD^' 'HEAD'
18:20:08.558999 run-command.c:369       trace: run_command: 'diff' '--raw' '--no-abbrev' '-z' 'HEAD^' 'HEAD'
18:20:08.569000 git.c:371               trace: built-in: git 'diff' '--raw' '--no-abbrev' '-z' 'HEAD^' 'HEAD'
18:20:08.641007 run-command.c:369       trace: run_command: 'difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a07672/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a07672/right/'
18:20:08.651008 git.c:596               trace: exec: 'git-difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a07672/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a07672/right/'
18:20:08.651008 run-command.c:369       trace: run_command: 'git-difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a07672/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a07672/right/'
18:20:08.731016 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'
18:20:08.756019 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.path'
18:20:08.773021 git.c:371               trace: built-in: git 'config' 'mergetool.beyondcompare3dd.path'
18:20:08.802023 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'
18:20:08.826026 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'

@whoisj
Copy link

whoisj commented Apr 4, 2017

Since '^' is a Windows path escape character, can you try '~' for the same effect?

Does that work around the issue?

@Radrik5
Copy link
Author

Radrik5 commented Apr 4, 2017

No.

$ GIT_TRACE=1 git difftool --tool=beyondcompare3dd --dir-diff HEAD~~ HEAD~
20:46:14.323042 git.c:371               trace: built-in: git 'difftool' '--tool=beyondcompare3dd' '--dir-diff' 'HEAD~~' 'HEAD~'
20:46:14.332042 run-command.c:369       trace: run_command: 'diff' '--raw' '--no-abbrev' '-z' 'HEAD~~' 'HEAD~'
20:46:14.344042 git.c:371               trace: built-in: git 'diff' '--raw' '--no-abbrev' '-z' 'HEAD~~' 'HEAD~'
fatal: cannot create directory at '': No such file or directory

@Radrik5
Copy link
Author

Radrik5 commented Apr 4, 2017

It's more about commits than refspecs:

client $ GIT_TRACE=1 git difftool --tool=beyondcompare3dd --dir-diff 0be29d4f 81b9fdea7a
20:48:58.865042 git.c:371               trace: built-in: git 'difftool' '--tool=beyondcompare3dd' '--dir-diff' '0be29d4f' '81b9fdea7a'
20:48:58.884042 run-command.c:369       trace: run_command: 'diff' '--raw' '--no-abbrev' '-z' '0be29d4f' '81b9fdea7a'
20:48:58.898042 git.c:371               trace: built-in: git 'diff' '--raw' '--no-abbrev' '-z' '0be29d4f' '81b9fdea7a'
fatal: cannot create directory at '': No such file or directory

client $ GIT_TRACE=1 git difftool --tool=beyondcompare3dd --dir-diff 81b9fdea7a 0be29d4f
20:49:10.834042 git.c:371               trace: built-in: git 'difftool' '--tool=beyondcompare3dd' '--dir-diff' '81b9fdea7a' '0be29d4f'
20:49:10.871042 run-command.c:369       trace: run_command: 'diff' '--raw' '--no-abbrev' '-z' '81b9fdea7a' '0be29d4f'
20:49:10.881042 git.c:371               trace: built-in: git 'diff' '--raw' '--no-abbrev' '-z' '81b9fdea7a' '0be29d4f'
20:49:10.959042 run-command.c:369       trace: run_command: 'difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a13596/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a13596/right/'
20:49:10.969042 git.c:596               trace: exec: 'git-difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a13596/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a13596/right/'
20:49:10.969042 run-command.c:369       trace: run_command: 'git-difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a13596/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a13596/right/'
20:49:11.034042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'
20:49:11.061042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.path'
20:49:11.080042 git.c:371               trace: built-in: git 'config' 'mergetool.beyondcompare3dd.path'
20:49:11.124042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'
20:49:11.156042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'

And it depends on the HEAD ref:

client $ git checkout HEAD^
HEAD is now at 81b9fdea7a...

client $ GIT_TRACE=1 git difftool --tool=beyondcompare3dd --dir-diff 0be29d4f 81b9fdea7a
20:50:58.573042 git.c:371               trace: built-in: git 'difftool' '--tool=beyondcompare3dd' '--dir-diff' '0be29d4f' '81b9fdea7a'
20:50:58.575042 run-command.c:369       trace: run_command: 'diff' '--raw' '--no-abbrev' '-z' '0be29d4f' '81b9fdea7a'
20:50:58.584042 git.c:371               trace: built-in: git 'diff' '--raw' '--no-abbrev' '-z' '0be29d4f' '81b9fdea7a'
20:50:58.629042 run-command.c:369       trace: run_command: 'difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a11972/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a11972/right/'
20:50:58.638042 git.c:596               trace: exec: 'git-difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a11972/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a11972/right/'
20:50:58.638042 run-command.c:369       trace: run_command: 'git-difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a11972/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a11972/right/'
20:50:58.695042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'
20:50:58.716042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.path'
20:50:58.735042 git.c:371               trace: built-in: git 'config' 'mergetool.beyondcompare3dd.path'
20:50:58.762042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'
20:50:58.788042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'

Same with the branch:

client $ git checkout -b test HEAD^
Switched to a new branch 'test'

client $ GIT_TRACE=1 git difftool --tool=beyondcompare3dd --dir-diff 0be29d4f 81b9fdea7a
20:53:20.545042 git.c:371               trace: built-in: git 'difftool' '--tool=beyondcompare3dd' '--dir-diff' '0be29d4f' '81b9fdea7a'
20:53:20.546042 run-command.c:369       trace: run_command: 'diff' '--raw' '--no-abbrev' '-z' '0be29d4f' '81b9fdea7a'
20:53:20.558042 git.c:371               trace: built-in: git 'diff' '--raw' '--no-abbrev' '-z' '0be29d4f' '81b9fdea7a'
20:53:20.604042 run-command.c:369       trace: run_command: 'difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a06512/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a06512/right/'
20:53:20.613042 git.c:596               trace: exec: 'git-difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a06512/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a06512/right/'
20:53:20.614042 run-command.c:369       trace: run_command: 'git-difftool--helper' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a06512/left/' 'C:\Users\dmitry\AppData\Local\Temp\git-difftool.a06512/right/'
20:53:20.679042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'
20:53:20.700042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.path'
20:53:20.718042 git.c:371               trace: built-in: git 'config' 'mergetool.beyondcompare3dd.path'
20:53:20.744042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'
20:53:20.770042 git.c:371               trace: built-in: git 'config' 'difftool.beyondcompare3dd.cmd'

@Radrik5 Radrik5 closed this as completed Apr 4, 2017
@Radrik5 Radrik5 reopened this Apr 4, 2017
@dscho
Copy link
Member

dscho commented Apr 4, 2017

@Radrik5 since this is a private repository, can you try to anonymize it? Effectively, what you would do is to call git init anonymized && git fast-export --anonymize --all | git -C anonymized fast-import and then verify that you can reproduce the issue in anonymized/. If you can reproduce, I would love to have a go at it, if you want, you can share with me alone and I will delete the related data as soon as I fixed the problem.

Of course, you could also spend some time to try to wiggle down the test case you have:

  1. clone the repository
  2. verify that the problem persists in the clone
  3. verify that it persists if you specify the tree objects rather than the commit objects
  4. verify that it persists if you create two tags referencing the tree objects directly, then refer to the tags
  5. verify that it persists if you create a new Git repository and fetch only those two tags
  6. try to reduce the tree objects by liberally removing files from them, verifying that you still can reproduce the problem
  7. modify the contents of the files until the problem goes away (and then revert the latest change that "fixes" the problem)

In essence, reduce the problem to a manageable size. Ideally we will end up with a new test case in t7800-difftool.sh that fails initially.

@Radrik5
Copy link
Author

Radrik5 commented Apr 5, 2017

Anonymized repo didn't have the exact same problem but I've found several buggy commits in the git-for-windows/git repo using the following script:

#!/bin/sh

git config --global difftool.noop.cmd true

git rev-list --all | while read commit
do
   if ! git difftool --tool=noop --dir-diff $commit^ $commit
   then
      echo "Found $commit"
   fi
   if ! git difftool --tool=noop --dir-diff $commit $commit^
   then
      echo "Found $commit (reverted)"
   fi
done

Top 24 commits:

error: unable to create file : No such file or directory
error: could not write '.gitignore'
Found fe84de0488c1f6229e343c893fdb5a0cbad4919b

error: unable to create file : No such file or directory
error: could not write 'Makefile'
Found 1636095f76801f6de551f95ec5346dc201ae2791

error: unable to create file F:/Projects/BatchEntry/git/builtin/diff.c: Is a directory
error: could not write 'builtin/fetch-pack.c'
Found 0adb77395facee516d58e14aabedf14a08390f1e (reverted)

error: unable to create file Documentation/Makefile: Is a directory
error: could not write 'Documentation/Makefile'
Found 148d43f19f919d1bd19cb37baa12213cea3e5b9f (reverted)

error: unable to create file : No such file or directory
error: could not write '.gitignore'
Found 5e850f7cc7b7c2d1f142ab726ec3085cde9752cf

error: unable to create file : No such file or directory
error: could not write 'Makefile'
Found 5c45bcff3953b7422dc6647db766b957af08d5b7

error: unable to create file : No such file or directory
error: could not write '.gitignore'
Found 84a8434c97d0506dc221bb1ad2ecfe892c3b64bc

error: unable to create file : No such file or directory
error: could not write 'Makefile'
Found 9bba66397799415248fa96e946e8ed6929559ee3

error: unable to create file Documentation/config.txt: Is a directory
error: could not write 'Documentation/config.txt'
Found 1318425e04b7582f6167c661fc2d3c0f1f3a5b27

error: unable to create file .gitignore: Is a directory
error: could not write '.gitignore'
Found 72a36cb46f3fbb1928114052c6496e9e2c0f131b (reverted)

error: unable to create file : No such file or directory
error: could not write '.gitignore'
Found 77f10a991749d55164ab8ef4bd481edb3883cb44

error: unable to create file : No such file or directory
error: could not write 'Makefile'
Found 2c3954c4f0ccf91721ceb448927a4465bc8c348b

fatal: cannot create directory at '': No such file or directory
Found a85e2699877de3d138db1bfb36ced92d4c0ff9dd

error: unable to create file : No such file or directory
error: could not write 'Makefile'
Found 6aba8fdce1619995d46ef7edcc3aae7fbe3af80c

error: unable to create file Documentation/git-status.txt: Is a directory
error: could not write 'Documentation/git-status.txt'
Found f2e5a85c3a14bb13c5b034122bea9e76daf82331

error: unable to create file .gitignore: Is a directory
error: could not write '.gitignore'
Found e9d66a561ff6af61ad152143260b6ceec62fc01a (reverted)

error: unable to create file Documentation/Makefile: Is a directory
error: could not write 'Documentation/Makefile'
Found c6b3e7e663aa5affbe927d167007b6cabad364db

fatal: cannot create directory at 'ș??': Invalid argument
Found 3d7ec2dd01874b3961e81b34083827bc6247430e (reverted)

error: unable to create file : No such file or directory
error: could not write 'Makefile'
Found 06cf24bcf8ade48877f845947f9dc5bcd3c7fcb1

fatal: cannot create directory at '': No such file or directory
Found f4cd896e7a06a965190a11a2cc7bc14190bb94a5 (reverted)

fatal: cannot create directory at '': No such file or directory
Found a4b58b14f433333802b0f4dddb2a847b9fcb4f4e

error: unable to create file Documentation/RelNotes/2.13.0.txt: Is a directory
error: could not write 'Documentation/RelNotes/2.13.0.txt'
Found 2903a06b5d5f1b59b30b0eb9177269521cf567cf (reverted)

error: unable to create file : No such file or directory
error: could not write '.gitignore'
Found bf35f66f8106be62d497818fc2ff7fd93454a520

error: unable to create file : No such file or directory
error: could not write 'Makefile'
Found ad9dc0d37c718a1d6f9d2c4543edbd57c2d846f5

You can use any of them for testing. The interesting thing here is that difftool fails to create folders for commit changes (from parent to commit) but it can successfully create folders for reverted changes (from commit to parent).

The error messages are different but probably the root cause is the same.

MCVE:

# I created a fork to freeze history because the problem depends on HEAD
$ git clone git@github.com:Radrik5/git.git

$ cd git
$ git config --global difftool.noop.cmd true

$ git difftool --tool=noop --dir-diff a4b58b14f433333802b0f4dddb2a847b9fcb4f4e^ a4b58b14f433333802b0f4dddb2a847b9fcb4f4e
fatal: cannot create directory at '': No such file or directory

@kgybels
Copy link

kgybels commented Apr 5, 2017

@Radrik5

Is there something like GIT_TRACE=1 that can help to understand what causes the error?

If you're willing to debug this then you can give Compiling Git with Visual Studio a try. You only need Visual Studio and Git for Windows, and you will be able to build and debug git. I would recommend VS2015, because the projects are generated for that version.

Note that I could not reproduce with the given MCVE.

@Radrik5
Copy link
Author

Radrik5 commented Apr 5, 2017

@kgybels could you run the script? Does it find anything in your repo?

@dscho dscho self-assigned this Apr 5, 2017
@dscho dscho added this to the v2.12.2(2) milestone Apr 5, 2017
@dscho
Copy link
Member

dscho commented Apr 5, 2017

@Radrik5 I can reproduce the issue, excellent, thanks!

@kgybels
Copy link

kgybels commented Apr 5, 2017

@Radrik5

could you run the script? Does it find anything in your repo?

It's already running for an hour now, nothing printed yet. I will abort it, since @dscho can reproduce on his end.

@dscho dscho closed this as completed in 7723f38 Apr 5, 2017
dscho added a commit to git-for-windows/build-extra that referenced this issue Apr 5, 2017
`git difftool -d` [no longer crashes
randomly](git-for-windows/git#1124).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@Radrik5
Copy link
Author

Radrik5 commented Apr 6, 2017

I confirm that the issue is fixed in 2.12.2(2).

@dscho
Copy link
Member

dscho commented Apr 7, 2017

@Radrik5 thank you for testing!

git-for-windows-ci pushed a commit that referenced this issue Apr 12, 2017
The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

Let's just copy the strings and be done with it.

This fixes #1124

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this issue Apr 12, 2017
The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

Let's just copy the strings and be done with it.

This fixes #1124

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit that referenced this issue Apr 13, 2017
The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

Let's just copy the strings and be done with it.

This fixes #1124

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit that referenced this issue Apr 13, 2017
The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

Let's just copy the strings and be done with it.

This fixes #1124

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/git that referenced this issue Apr 13, 2017
The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

A contrived test case shows the problem where a file with a long enough
name to force the strbuf to grow is up-to-date (hence the code path is
used where the work tree's version of the file is reused), and then a
file that is not up-to-date needs to be written (hence the code path is
used where checkout_entry() uses the previously recorded base_dir that
is invalid by now).

Let's just copy the base_dir strings for use with checkout_entry(),
never touch them until the end, and release them then. This is an easily
verifiable fix (as opposed to the next-obvious alternative: to re-set
base_dir after every loop iteration).

This fixes git-for-windows#1124

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
fengguang pushed a commit to 0day-ci/git that referenced this issue Apr 14, 2017
The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

A contrived test case shows the problem where a file with a long enough
name to force the strbuf to grow is up-to-date (hence the code path is
used where the work tree's version of the file is reused), and then a
file that is not up-to-date needs to be written (hence the code path is
used where checkout_entry() uses the previously recorded base_dir that
is invalid by now).

Let's just copy the base_dir strings for use with checkout_entry(),
never touch them until the end, and release them then. This is an easily
verifiable fix (as opposed to the next-obvious alternative: to re-set
base_dir after every loop iteration).

This fixes git-for-windows#1124

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
gitster pushed a commit to git/git that referenced this issue Apr 15, 2017
The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

A contrived test case shows the problem where a file with a long enough
name to force the strbuf to grow is up-to-date (hence the code path is
used where the work tree's version of the file is reused), and then a
file that is not up-to-date needs to be written (hence the code path is
used where checkout_entry() uses the previously recorded base_dir that
is invalid by now).

Let's just copy the base_dir strings for use with checkout_entry(),
never touch them until the end, and release them then. This is an easily
verifiable fix (as opposed to the next-obvious alternative: to re-set
base_dir after every loop iteration).

This fixes git-for-windows#1124

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dscho added a commit that referenced this issue Apr 26, 2017
The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

A contrived test case shows the problem where a file with a long enough
name to force the strbuf to grow is up-to-date (hence the code path is
used where the work tree's version of the file is reused), and then a
file that is not up-to-date needs to be written (hence the code path is
used where checkout_entry() uses the previously recorded base_dir that
is invalid by now).

Let's just copy the base_dir strings for use with checkout_entry(),
never touch them until the end, and release them then. This is an easily
verifiable fix (as opposed to the next-obvious alternative: to re-set
base_dir after every loop iteration).

This fixes #1124

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-for-windows-ci pushed a commit that referenced this issue Apr 26, 2017
The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

A contrived test case shows the problem where a file with a long enough
name to force the strbuf to grow is up-to-date (hence the code path is
used where the work tree's version of the file is reused), and then a
file that is not up-to-date needs to be written (hence the code path is
used where checkout_entry() uses the previously recorded base_dir that
is invalid by now).

Let's just copy the base_dir strings for use with checkout_entry(),
never touch them until the end, and release them then. This is an easily
verifiable fix (as opposed to the next-obvious alternative: to re-set
base_dir after every loop iteration).

This fixes #1124

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-for-windows-ci pushed a commit that referenced this issue May 10, 2017
The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

A contrived test case shows the problem where a file with a long enough
name to force the strbuf to grow is up-to-date (hence the code path is
used where the work tree's version of the file is reused), and then a
file that is not up-to-date needs to be written (hence the code path is
used where checkout_entry() uses the previously recorded base_dir that
is invalid by now).

Let's just copy the base_dir strings for use with checkout_entry(),
never touch them until the end, and release them then. This is an easily
verifiable fix (as opposed to the next-obvious alternative: to re-set
base_dir after every loop iteration).

This fixes #1124

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
benpeart pushed a commit that referenced this issue Jan 18, 2018
The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

Let's just copy the strings and be done with it.

This was reported at http://stackoverflow.microsoft.com/q/40758/23695 and
at #1124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants