git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Git config "ignorecase = true" has issues
@ 2019-04-19 19:28 Ax Da
  2019-04-24 19:11 ` Torsten Bögershausen
  0 siblings, 1 reply; 6+ messages in thread
From: Ax Da @ 2019-04-19 19:28 UTC (permalink / raw)
  To: git


We're working on Windows machines and have been experiencing issues with the current implementation of Git with config setting "core.ignorecase = true" (which is the default on Windows machines and repositories created on Windows machines):

Renaming files in a repository by only changing their case (changing a capital letter to its small equivalent and vice versa) is ignored by Git. Git retains the original case in the repository and all contributors will continue to see the ole file name which leads to confusion and issues with Open Source tools programmed to not ignore file name case.

Currently there is no way to convey the new file name (only differing in case) to Git when "core.ignorecase = true".

Hence, I propose to alter the behaviour of Git when "core.ignorecase = true": A repository's file name changes should be recognized as a RENAME operation and be propagated to the repository even when the new file name only differs from the old file name in case.

Thanks,
Axel Dahmen

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Git config "ignorecase = true" has issues
  2019-04-19 19:28 Ax Da
@ 2019-04-24 19:11 ` Torsten Bögershausen
  0 siblings, 0 replies; 6+ messages in thread
From: Torsten Bögershausen @ 2019-04-24 19:11 UTC (permalink / raw)
  To: Ax Da; +Cc: git

On Fri, Apr 19, 2019 at 09:28:32PM +0200, Ax Da wrote:
>
> We're working on Windows machines and have been experiencing issues with the current implementation of Git with config setting "core.ignorecase = true" (which is the default on Windows machines and repositories created on Windows machines):
>
> Renaming files in a repository by only changing their case (changing a capital letter to its small equivalent and vice versa) is ignored by Git. Git retains the original case in the repository and all contributors will continue to see the ole file name which leads to confusion and issues with Open Source tools programmed to not ignore file name case.
>
> Currently there is no way to convey the new file name (only differing in case) to Git when "core.ignorecase = true".
>
> Hence, I propose to alter the behaviour of Git when "core.ignorecase = true": A repository's file name changes should be recognized as a RENAME operation and be propagated to the repository even when the new file name only differs from the old file name in case.

You can rename files like this:
git mv File.txt file.txt
git commit

and Git will record the changes.

The main problem is, that after the rename, and may be on another machine after a pull,
Git checks with the file system, if any updates in the working tree are needed.
In human speech, Git asks the file system:
Do we have a file named "file.txt" on disk ?
And Windows answers: Yes we have.
Even if the file is named "File.txt" and Git asks for "file.txt".

You can try it yourself.
Run
cat File.txt
under the Git shell (bash)
or
type File.txt
under cmd.exe

That is how it is.

If you really need the updated name "file.txt", you can delete all files in the worktree
rm -rf *
followed by
git reset --hard

But in any case, run
git status
before and make sure that your working tree is clean.

>
> Thanks,
> Axel Dahmen

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Git config "ignorecase = true" has issues
@ 2019-05-05 10:11 Ax Da
  0 siblings, 0 replies; 6+ messages in thread
From: Ax Da @ 2019-05-05 10:11 UTC (permalink / raw)
  Cc: git

Thanks for replying. Do you know how the query you mentioned ("Do we have a file named "file.txt" on disk?") is implemented in git?

I'd suggest to use the C++ Windows API function FindFirstFileW() and then manually compare the result with the queried file name, like:



bool fileExists(const WCHAR_T *fileName, bool ignoreCase)
{
  WIN32_FIND_DATAW fileData;
  bool fileExists = false;
  int (*strCmp)(const wchar_t *string1, const wchar_t *string2, size_t count)
      = ignoreCase ? _wcsnicmp : wcsncmp;
);

  if (FindFirstFileW(fileName, fileData) != INVALID_HANDLE_VALUE)
  {
    if (!strCmp(fileName, fileData.cFileName, wcsnlen(fileName, MAX_PATH) + 1)) fileExists = true;
 
    FindClose(fileData);
  }
 
  return fileExists;
}



---------------------------------------------------------------------------

Gesendet: Mittwoch, 24. April 2019 um 21:11 Uhr
Von: "Torsten Bögershausen" <tboegi@web.de>
An: "Ax Da" <discussion@gmx.net>
Cc: git@vger.kernel.org
Betreff: Re: Git config "ignorecase = true" has issues
On Fri, Apr 19, 2019 at 09:28:32PM +0200, Ax Da wrote:
>
> We're working on Windows machines and have been experiencing issues with the current implementation of Git with config setting "core.ignorecase = true" (which is the default on Windows machines and repositories created on Windows machines):
>
> Renaming files in a repository by only changing their case (changing a capital letter to its small equivalent and vice versa) is ignored by Git. Git retains the original case in the repository and all contributors will continue to see the ole file name which leads to confusion and issues with Open Source tools programmed to not ignore file name case.
>
> Currently there is no way to convey the new file name (only differing in case) to Git when "core.ignorecase = true".
>
> Hence, I propose to alter the behaviour of Git when "core.ignorecase = true": A repository's file name changes should be recognized as a RENAME operation and be propagated to the repository even when the new file name only differs from the old file name in case.

You can rename files like this:
git mv File.txt file.txt
git commit

and Git will record the changes.

The main problem is, that after the rename, and may be on another machine after a pull,
Git checks with the file system, if any updates in the working tree are needed.
In human speech, Git asks the file system:
Do we have a file named "file.txt" on disk ?
And Windows answers: Yes we have.
Even if the file is named "File.txt" and Git asks for "file.txt".

You can try it yourself.
Run
cat File.txt
under the Git shell (bash)
or
type File.txt
under cmd.exe

That is how it is.

If you really need the updated name "file.txt", you can delete all files in the worktree
rm -rf *
followed by
git reset --hard

But in any case, run
git status
before and make sure that your working tree is clean.

>
> Thanks,
> Axel Dahmen

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Git config "ignorecase = true" has issues
@ 2019-05-18 12:58 Ax Da
  2019-05-18 16:38 ` Johannes Sixt
  0 siblings, 1 reply; 6+ messages in thread
From: Ax Da @ 2019-05-18 12:58 UTC (permalink / raw)
  Cc: git

Anyone who likes to fix this issue?
-----------------------------------


Gesendet: Sonntag, 05. Mai 2019 um 12:11 Uhr
Von: "Ax Da" <discussion@gmx.net>
An: unlisted-recipients:;
Cc: git@vger.kernel.org
Betreff: Re: Git config "ignorecase = true" has issues
Thanks for replying. Do you know how the query you mentioned ("Do we have a file named "file.txt" on disk?") is implemented in git?

I'd suggest to use the C++ Windows API function FindFirstFileW() and then manually compare the result with the queried file name, like:



bool fileExists(const WCHAR_T *fileName, bool ignoreCase)
{
  WIN32_FIND_DATAW fileData;
  bool fileExists = false;
int (*strCmp)(const wchar_t *string1, const wchar_t *string2, size_t count)
= ignoreCase ? _wcsnicmp : wcsncmp;
);

  if (FindFirstFileW(fileName, fileData) != INVALID_HANDLE_VALUE)
  {
    if (!strCmp(fileName, fileData.cFileName, wcsnlen(fileName, MAX_PATH) + 1)) fileExists = true;
 
    FindClose(fileData);
  }
 
  return fileExists;
}



---------------------------------------------------------------------------

Gesendet: Mittwoch, 24. April 2019 um 21:11 Uhr
Von: "Torsten Bögershausen" <tboegi@web.de>
An: "Ax Da" <discussion@gmx.net>
Cc: git@vger.kernel.org
Betreff: Re: Git config "ignorecase = true" has issues
On Fri, Apr 19, 2019 at 09:28:32PM +0200, Ax Da wrote:
>
> We're working on Windows machines and have been experiencing issues with the current implementation of Git with config setting "core.ignorecase = true" (which is the default on Windows machines and repositories created on Windows machines):
>
> Renaming files in a repository by only changing their case (changing a capital letter to its small equivalent and vice versa) is ignored by Git. Git retains the original case in the repository and all contributors will continue to see the ole file name which leads to confusion and issues with Open Source tools programmed to not ignore file name case.
>
> Currently there is no way to convey the new file name (only differing in case) to Git when "core.ignorecase = true".
>
> Hence, I propose to alter the behaviour of Git when "core.ignorecase = true": A repository's file name changes should be recognized as a RENAME operation and be propagated to the repository even when the new file name only differs from the old file name in case.

You can rename files like this:
git mv File.txt file.txt
git commit

and Git will record the changes.

The main problem is, that after the rename, and may be on another machine after a pull,
Git checks with the file system, if any updates in the working tree are needed.
In human speech, Git asks the file system:
Do we have a file named "file.txt" on disk ?
And Windows answers: Yes we have.
Even if the file is named "File.txt" and Git asks for "file.txt".

You can try it yourself.
Run
cat File.txt
under the Git shell (bash)
or
type File.txt
under cmd.exe

That is how it is.

If you really need the updated name "file.txt", you can delete all files in the worktree
rm -rf *
followed by
git reset --hard

But in any case, run
git status
before and make sure that your working tree is clean.

>
> Thanks,
> Axel Dahmen

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Git config "ignorecase = true" has issues
  2019-05-18 12:58 Git config "ignorecase = true" has issues Ax Da
@ 2019-05-18 16:38 ` Johannes Sixt
  2019-05-21  2:31   ` Torsten Bögershausen
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Sixt @ 2019-05-18 16:38 UTC (permalink / raw)
  To: Ax Da; +Cc: git

Am 18.05.19 um 14:58 schrieb Ax Da:
> You can rename files like this:
> git mv File.txt file.txt

On a case-insensitive, case-preserving filesystem, a case-only rename
operation is better performed in two steps that do not just change the case:

git mv File.txt  file.txtx
git mv file.txtx file.txt

> git commit
> 
> and Git will record the changes.

-- Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Git config "ignorecase = true" has issues
  2019-05-18 16:38 ` Johannes Sixt
@ 2019-05-21  2:31   ` Torsten Bögershausen
  0 siblings, 0 replies; 6+ messages in thread
From: Torsten Bögershausen @ 2019-05-21  2:31 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Ax Da, git

On Sat, May 18, 2019 at 06:38:39PM +0200, Johannes Sixt wrote:
> Am 18.05.19 um 14:58 schrieb Ax Da:
> > You can rename files like this:
> > git mv File.txt file.txt
>
> On a case-insensitive, case-preserving filesystem, a case-only rename
> operation is better performed in two steps that do not just change the case:
>
> git mv File.txt  file.txtx
> git mv file.txtx file.txt

Is this still needed in latest versions of Git, please see below  ?
A quick test shows that both the file is renamed and the index is updated:

user@mac:~/projects/git/git.pu> git mv Makefile MAKEFILE
user@mac:~/projects/git/git.pu> ls -l MAKEFILE
-rw-r--r--  1 tb  staff  100301 Apr 17 16:53 MAKEFILE

user@mac:~/projects/git/git.pu> git status
HEAD detached at git.git/pu
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        renamed:    Makefile -> MAKEFILE



  commit baa37bff9a845471754d3f47957d58a6ccc30058
  Author: David Turner <dturner@twitter.com>
  Date:   Thu May 8 10:23:34 2014 -0700

    mv: allow renaming to fix case on case insensitive filesystems

    "git mv hello.txt Hello.txt" on a case insensitive filesystem
     always triggers "destination already exists" error, because these
    two names refer to the same path from the filesystem's point of
    view, and requires the user to give "--force" when correcting the
    case of the path recorded in the index and in the next commit.

    Detect this case and allow it without requiring "--force".

    Signed-off-by: David Turner <dturner@twitter.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>


[snip]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-05-21  2:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-18 12:58 Git config "ignorecase = true" has issues Ax Da
2019-05-18 16:38 ` Johannes Sixt
2019-05-21  2:31   ` Torsten Bögershausen
  -- strict thread matches above, loose matches on Subject: below --
2019-05-05 10:11 Ax Da
2019-04-19 19:28 Ax Da
2019-04-24 19:11 ` Torsten Bögershausen

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).