Skip to content

Drive letter case-sensitive #735

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

Closed
1 task done
midlan opened this issue Apr 19, 2016 · 5 comments
Closed
1 task done

Drive letter case-sensitive #735

midlan opened this issue Apr 19, 2016 · 5 comments
Milestone

Comments

@midlan
Copy link

midlan commented Apr 19, 2016

  • 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? 32-bit or 64-bit? Include the
    output of git version as well.

64-bit

git version 2.8.0.windows.1
  • Which version of Windows are you running? 32-bit or 64-bit?

Windows 10 Pro 64-bit

  • What options did you set as part of the installation? Or did you choose the
    defaults?

yes, defaults, git in %PATH%

  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

no

Details

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

windows native cmd.exe

1. mkdir "c:\repo"
2. cmd /K "cd c:\repo\"
3. git init
4. echo "content" > file.txt
5. git add C:\repo\file.txt

When your drive letter in step 2 is lower-case (in this example c:) and in step 5 is upper-case it will cause fatal. I think it's a bug, because windows path is case-insensitive.

  • What did you expect to occur after running these commands?

Adding a file.txt to future commit.

  • What actually happened instead?
fatal: C:\repo\file.txt: 'C:\repo\file.txt' is outside repository
  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

no, it's global problem

@fourpastmidnight
Copy link

Hmm, can you try something for me, I have a hunch:

C:\> git add /C:\repo\file.txt

@midlan
Copy link
Author

midlan commented May 20, 2016

It returns this:

c:\repo>git add /C:\repo\file.txt
fatal: Could not switch to '/C:/': Invalid argument

@fourpastmidnight
Copy link

fourpastmidnight commented May 20, 2016

@midlan: OK, thanks. I'm trying to determine if this has anything to do with MSYS POSIX path conversion or not, or maybe something with git-add itself and the path separators being used. Let's try these variations, too, for thoroughness:

C:\> git add C:/repo/file.txt
REM If this doesn't work, maybe also try:
C:\> git add /C:/repo/file.txt

For the record, since you're in a command prompt, I wouldn't think this to be the case, but, like I said, for thoroughness.

@midlan
Copy link
Author

midlan commented May 20, 2016

@fourpastmidnight:

c:\repo>git add C:/repo/file.txt
fatal: C:/repo/file.txt: 'C:/repo/file.txt' is outside repository`
c:\repo>git add /C:/repo/file.txt
fatal: Could not switch to '/C:/': Invalid argument

But I don't understand why you're not trying it on your PC. You don't use windows?

@dscho
Copy link
Member

dscho commented May 21, 2016

But I don't understand why you're not trying it on your PC.

@midlan Traditionally, the Git for Windows project suffers no shortage of bug reporters, but a shortage of contributors who dive into the code and fix bugs (keep in mind that Git for Windows is downloaded ~1.5 million times, yet there are fewer active Git for Windows contributors than you have fingers on your right hand).

That means that people in the latter category invariably have to pick and choose which fraction of the bug reports they work on. One easy way to triage the tickets is to assess how much the bug reporters are willing to work on the problem themselves: it is much more fun to work on those tickets, and they also have a much better chance of being resolved quickly.

Hence I encourage you to consider adding a test to Git's regression test suite, and contributing this as a Pull Request. See the test suite documentation and a good example of a test.

Let's take a look at your MCVE (thanks BTW for making one that works! You'd be surprised how surprising that is to frequent readers of this here bug tracker):

mkdir "c:\repo"
cmd /K "cd c:\repo\"
git init
echo "content" > file.txt
git add C:\repo\file.txt

The first thing to notice is that we cannot go and create top-level directories in C:\. But that is not even necessary: any repository will have a drive letter. And we can use an absolute path that mismatches Git's idea of the current directory.

And then we do not even need the interactive cmd any longer: we can pass the absolute path to Git directly.

Inside a shell script, we can get at the absolute Windows path with: pwd -W.

So here is a sketch how to get the absolute path to the current directory with a drive letter that has the opposite case of what Git expects it to be:

dir="$(pwd -W)" &&
case "$dir" in
[A-Za-z]:*)
        # change case of the drive letter only
        drive_letter="$(echo "${dir%%:*}" | tr "A-Za-z" "a-zA-Z")" &&
        dir2="$drive_letter${dir#?}"
        ;;
*)
        [... skip test...]
esac

Another thing to note: we will want to guard the test so that it only runs on Windows because it makes little sense to run it on, say, Linux (and Git's source code is kept adamantly cross-platform). So it should look somewhat like this:

test_expect_failure MINGW 'drive letter is case-insensitive' '
        ...
'

(I say "failure" here because it is a known breakage.)

@dscho dscho closed this as completed in 7df5db8 Apr 5, 2017
dscho added a commit to git-for-windows/build-extra that referenced this issue Apr 7, 2017
Calling `git add` with an absolute path using different
upper/lower case than recorded on disk [will now work as
expected](git-for-windows/git#735) instead
of claiming that the paths are outside the repository.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho added this to the v2.12.3 milestone Apr 7, 2017
git-for-windows-ci pushed a commit that referenced this issue Apr 12, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Apr 12, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
git-for-windows-ci pushed a commit that referenced this issue Apr 13, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
git-for-windows-ci pushed a commit that referenced this issue Apr 13, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Apr 16, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
git-for-windows-ci pushed a commit that referenced this issue Apr 17, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
git-for-windows-ci pushed a commit that referenced this issue Apr 17, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
git-for-windows-ci pushed a commit that referenced this issue Apr 17, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Apr 20, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Apr 26, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Apr 26, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
git-for-windows-ci pushed a commit that referenced this issue Apr 26, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue May 2, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue May 4, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
git-for-windows-ci pushed a commit that referenced this issue May 10, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue May 10, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue May 10, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
csware pushed a commit to TortoiseGit/tgit that referenced this issue May 13, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue May 15, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
git-for-windows-ci pushed a commit that referenced this issue May 16, 2017
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue May 29, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue May 29, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
orgads pushed a commit to orgads/git that referenced this issue Jun 22, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
orgads pushed a commit to orgads/git that referenced this issue Jun 22, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
orgads pushed a commit to orgads/git that referenced this issue Jun 22, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 22, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/git that referenced this issue Aug 22, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 23, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 23, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Aug 23, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
jamill pushed a commit to jamill/git that referenced this issue Aug 28, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
jamill pushed a commit to jamill/git that referenced this issue Sep 5, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
git-for-windows-ci pushed a commit that referenced this issue Sep 10, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
jamill pushed a commit to jamill/git that referenced this issue Sep 11, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
git-for-windows-ci pushed a commit that referenced this issue Sep 24, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this issue Oct 10, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes #735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/git that referenced this issue Dec 20, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/git that referenced this issue Dec 24, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/git that referenced this issue Dec 24, 2018
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/git that referenced this issue Jan 18, 2019
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
gitster pushed a commit to git/git that referenced this issue Jan 18, 2019
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
dscho added a commit to dscho/git that referenced this issue Feb 7, 2019
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes git-for-windows#735

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Junio C Hamano <[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

No branches or pull requests

3 participants