git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/2] Work around case-insensitivity issues with cwd on Windows

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 24, 2018, 09:19 UTC
Message-ID
<pull.54.v2.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.54.git.gitgitgadget@gmail.com>

On Windows, file names are recorded case-sensitively, but looked up case-insensitively. Therefore, it is possible to switch to a directory by using incorrect case, e.g. cd documentation will still get you into the Documentation subdirectory.

In Powershell, doing so will however report the current directory with the specified spelling rather than the one recorded on disk, and Git will get confused.

To remedy that, we fixed this in Git for Windows more than three years ago, and needed only a small fix a couple of months later to accommodate for the diverse scenarios encountered by the many Git for Windows users.

Not only to keep the story closer to what happened historically, but also to make it easier to follow, I refrained from squashing these two patches.

Side note: the second patch is technically not battle-tested for that long: it uses an API function that requires Windows Vista or later, and we only recently started to clean up Git for Windows' code to drop fallbacks for Windows XP. Read: this code used to load the GetFinalPathNameByHandle() function dynamically, and that is the only difference to the code that has been "battle-tested" for close to three years.

Changes since v1:
 * Fixed a grammar mistake in the second commit message.
Anton Serbulov (1):
  mingw: fix getcwd when the parent directory cannot be queried
Johannes Schindelin (1):
  mingw: ensure `getcwd()` reports the correct case
 compat/mingw.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)
base-commit: c4df23f7927d8d00e666a3c8d1b3375f1dc8a3c1
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-54%2Fdscho%2Fmingw-getcwd-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-54/dscho/mingw-getcwd-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/54
Range-diff vs v1:
 1:  e13ae2338 = 1:  e13ae2338 mingw: ensure `getcwd()` reports the correct case
 2:  3e3b1c3b1 ! 2:  87ef9ac63 mingw: fix getcwd when the parent directory cannot be queried
     @@ -4,7 +4,7 @@
      
          `GetLongPathName()` function may fail when it is unable to query
          the parent directory of a path component to determine the long name
     -    for that component. It happens, because of it uses `FindFirstFile()`
     +    for that component. It happens, because it uses `FindFirstFile()`
          function for each next short part of path. The `FindFirstFile()`
          requires `List Directory` and `Synchronize` desired access for a calling
          process.
-- 
gitgitgadget
Previous: Johannes SchindelinNext: Anton Serbulov via GitGitGadget
Message 7 of 12 in “Work around case-insensitivity issues with cwd on Windows”
  1. 0/2 Work around case-insensitivity issues with cwd on WindowsJohannes Schindelin via GitGitGadget, Oct 23, 2018
  2. 1/2 mingw: ensure `getcwd()` reports the correct caseJohannes Schindelin via GitGitGadget, Oct 23, 2018
  3. 2/2 mingw: fix getcwd when the parent directory cannot be queriedAnton Serbulov via GitGitGadget, Oct 23, 2018
  4. Stephen & Linda SmithOct 23, 2018
  5. Stephen SmithOct 23, 2018
  6. Johannes SchindelinOct 24, 2018
  7. 0/2 Work around case-insensitivity issues with cwd on WindowsJohannes Schindelin via GitGitGadget, Oct 24, 2018
  8. 2/2 mingw: fix getcwd when the parent directory cannot be queriedAnton Serbulov via GitGitGadget, Oct 24, 2018
  9. 1/2 mingw: ensure `getcwd()` reports the correct caseJohannes Schindelin via GitGitGadget, Oct 24, 2018
  10. Junio C HamanoOct 24, 2018
  11. Johannes SchindelinOct 24, 2018
  12. Junio C HamanoOct 25, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.