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

Unable to edit config file on network drive #226

Closed
nalla opened this issue Jun 29, 2015 · 5 comments
Closed

Unable to edit config file on network drive #226

nalla opened this issue Jun 29, 2015 · 5 comments

Comments

@nalla
Copy link

nalla commented Jun 29, 2015

The following command-chain works with 2.4.4 but not with 2.4.5. It works with a local drive like C:\ alright.

Steps to reproduce

cd /usr/src/git && git pull && git checkout -t origin/rebase-to-2.4.5
make clean && make -j8
# Map a network share to X:
rm -f X:/test
./git config -f X:\test svn-remote.svn.branches-maxRev 1
# -> succeeds
./git config -f X:\test svn-remote.svn.branches-maxRev 1
# -> fails with Rename from 'X:/test.lock' to 'X:/test' failed. Should I try again? (y/n)
git checkout v2.4.4.windows.2
make clean && make -j8
rm -f X:/test
./git config -f X:\test svn-remote.svn.branches-maxRev 1
# -> succeeds
./git config -f X:\test svn-remote.svn.branches-maxRev 1
# -> succeeds

Analysis

The error messages comes from mingw_rename function in compat/mingw.c. But git diff v2.4.4.windows.2..rebase-to-2.4.5 compat/mingw.c is empty. Maybe git diff v2.4.4.windows.2..rebase-to-2.4.5 config.c is the cause then.

I humble ask if anyone can reproduce this bug.

@nalla
Copy link
Author

nalla commented Jun 30, 2015

So far I found out that somehow the close for the test file is delayed or not even executed at all. See the procmon analysis below. The MoveFileExW function returns SHARING_VIOLATION, as seen in the trace below. What i did track down is that the close call that is being executed before lockfile.c even tries to rename the file is this one. @kblees since you refactored the renaming in mingw.c - maybe you have any ideas?

"Time of Day","Process Name","PID","Operation","Path","Result","Detail"
"11:18:35,5242466","git.exe","8108","CreateFile","\\remote.host\test\test.lock","SUCCESS","Desired Access: Read Attributes, Delete, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Open For Backup, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"11:18:35,5252744","git.exe","8108","QueryAttributeTagFile","\\remote.host\test\test.lock","SUCCESS","Attributes: A, ReparseTag: 0x0"
"11:18:35,5253114","git.exe","8108","QueryBasicInformationFile","\\remote.host\test\test.lock","SUCCESS","CreationTime: 30.06.2015 11:10:18, LastAccessTime: 30.06.2015 11:16:16, LastWriteTime: 30.06.2015 11:16:16, ChangeTime: 30.06.2015 11:16:16, FileAttributes: A"
"11:18:35,5302017","git.exe","8108","CreateFile","\\remote.host\test","SUCCESS","Desired Access: Write Data/Add File, Synchronize, Disposition: Open, Options: Open For Backup, Attributes: n/a, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Superseded"
"11:18:35,5357504","git.exe","8108","SetRenameInformationFile","\\remote.host\test\test.lock","SHARING VIOLATION","ReplaceIfExists: True, FileName: \\remote.host\test\test"
"11:18:35,5358329","git.exe","8108","CloseFile","\\remote.host\test\test.lock","SUCCESS",""
"11:18:35,5435852","git.exe","8108","CreateFile","\\remote.host\test\test","SUCCESS","Desired Access: Write Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Open For Backup, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"11:18:35,5443905","git.exe","8108","SetBasicInformationFile","\\remote.host\test\test","SUCCESS","CreationTime: 01.01.1601 02:00:00, LastAccessTime: 01.01.1601 02:00:00, LastWriteTime: 01.01.1601 02:00:00, ChangeTime: 01.01.1601 02:00:00, FileAttributes: AN"
"11:18:35,5455575","git.exe","8108","CloseFile","\\remote.host\test\test","SUCCESS",""
"11:18:35,5603613","git.exe","8108","CreateFile","\\remote.host\test\test","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open For Backup, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"11:18:35,5610020","git.exe","8108","QueryBasicInformationFile","\\remote.host\test\test","SUCCESS","CreationTime: 29.06.2015 12:26:05, LastAccessTime: 29.06.2015 12:26:05, LastWriteTime: 29.06.2015 12:26:05, ChangeTime: 30.06.2015 11:18:35, FileAttributes: A"
"11:18:35,5610244","git.exe","8108","CloseFile","\\remote.host\test\test","SUCCESS",""
"11:20:31,8243699","git.exe","8108","CreateFile","\\remote.host\test\test.lock","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open For Backup, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"11:20:31,8252595","git.exe","8108","QueryBasicInformationFile","\\remote.host\test\test.lock","SUCCESS","CreationTime: 30.06.2015 11:10:18, LastAccessTime: 30.06.2015 11:16:16, LastWriteTime: 30.06.2015 11:16:16, ChangeTime: 30.06.2015 11:16:16, FileAttributes: A"
"11:20:31,8252778","git.exe","8108","CloseFile","\\remote.host\test\test.lock","SUCCESS",""
"11:20:31,8318213","git.exe","8108","CreateFile","\\remote.host\test\test.lock","SUCCESS","Desired Access: Write Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Open For Backup, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"11:20:31,8328637","git.exe","8108","SetBasicInformationFile","\\remote.host\test\test.lock","SUCCESS","CreationTime: 01.01.1601 02:00:00, LastAccessTime: 01.01.1601 02:00:00, LastWriteTime: 01.01.1601 02:00:00, ChangeTime: 01.01.1601 02:00:00, FileAttributes: AN"
"11:20:31,8338574","git.exe","8108","CloseFile","\\remote.host\test\test.lock","SUCCESS",""
"11:20:31,8410566","git.exe","8108","CreateFile","\\remote.host\test\test.lock","SUCCESS","Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open For Backup, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"11:20:31,8422082","git.exe","8108","QueryAttributeTagFile","\\remote.host\test\test.lock","SUCCESS","Attributes: A, ReparseTag: 0x0"
"11:20:31,8422277","git.exe","8108","SetDispositionInformationFile","\\remote.host\test\test.lock","SUCCESS","Delete: True"
"11:20:31,8427819","git.exe","8108","CloseFile","\\remote.host\test\test.lock","SUCCESS",""

@nalla
Copy link
Author

nalla commented Jun 30, 2015

Nailed it!
The issue is with commit 3a1b312. The problem is that munmap(contents, contents_sz); moved past the commit_lock_file(lock) call. That seems to be a problem for files that are on windows shares. git.exe still holds a handle to device\mup\file_in_question

@kblees
Copy link

kblees commented Jun 30, 2015

Dito 😄

See #229

@nalla
Copy link
Author

nalla commented Jun 30, 2015

Yes! just saw that reference showing up right before clicking on comment ;)

@kblees kblees closed this as completed in 36d5d2e Jun 30, 2015
@dscho
Copy link
Member

dscho commented Jun 30, 2015

Thanks, both!

dscho pushed a commit to dscho/git that referenced this issue Jul 18, 2015
Renaming to an existing file doesn't work on Windows network shares if the
target file is open.

munmap() the old config file before commit_lock_file.

This fixes git-for-windows#226.

Signed-off-by: Karsten Blees <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
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

Successfully merging a pull request may close this issue.

3 participants