Skip to content

Open files are deleted by checkout #1653

Closed
@orgads

Description

@orgads
  • 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.17.0.windows.1.26.g82f1b61609
cpu: x86_64
built from commit: 82f1b6160988ab0a61edebef6ed1c3048b66a3a4
sizeof-long: 4
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 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

Editor Option: VIM
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: Enabled

Details

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

Git Bash

git init
echo first > foo
git add foo
git commit -m 'Initial commit'
git checkout -b other
echo second > foo
git commit -a -m 'Second'
(
  sleep 1
  git checkout master
  echo 'Press Ctrl-D now'
) &
cat >> foo
git status
  • What did you expect to occur after running these commands?

I expect that either checkout will fail, or it will wait until the file is released (with some reasonable timeout), then replace it.

  • What actually happened instead?

The file is deleted!

This issue happens all the time when working with Qt Creator, which parses header files constantly, so they're open for short periods. This was reported here. To workaround the issue, Qt Creator avoids using mmap in the clang library, but this did not completely solved the issue, only improved it. This is actually a Git (or MSYS?) bug, which should be solved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions