{"thread":{"id":"50367","subject":"Possible minor bug in Git","startedAt":"2019-01-31T07:01:36Z","lastAt":"2019-02-10T22:47:04Z","messageCount":10,"participants":["Angelo Melonas","Torsten Bögershausen","Giuseppe Crinò","Johannes Schindelin","Philip Oakley","Giuseppe Crino'"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"368216","messageId":"CAHYHVP+ty7i7a_abT-th_HR2X-8X6mLmpHPR_3VXv5LpWUsrhQ@mail.gmail.com","threadId":"50367","inReplyTo":null,"subject":"Possible minor bug in Git","fromName":"Angelo Melonas","fromEmail":"angelomelonas@gmail.com","sentAt":"2019-01-31T07:01:24Z","receivedAt":"2019-01-31T07:01:36Z","isPatch":false,"sender":{"key":"angelomelonas@gmail.com","avatar":null},"body":"Good day,\n\nI found a potential bug in Git for Windows. The bug can be reproduced\nas follows:\n\n1. Modify a file so that it shows up as \"untracked\" when executing the\n\"git status\" command.\n2. Attempt to \"git add\" the file, but change the case of a single\nletter. The command executes but no warning or error is displayed.\n3. Execute \"git status\" again and it still shows the file as \"untracked\".\n\nPlease let me know if I am mistaken. I also have a screenshot\ndemonstrating the \"bug\" which I cannot attach to this email, but which\ncan be requested.\n\nHave a great day.\n\nKind regards,\nAngelo Melonas\n"},{"id":"368221","messageId":"CAHYHVP+Dvbq_aOMy1_Kq0LHJsd4r+4GiP3N3R4A9ouAoJ4gw9g@mail.gmail.com","threadId":"50367","inReplyTo":"CAHYHVP+ty7i7a_abT-th_HR2X-8X6mLmpHPR_3VXv5LpWUsrhQ@mail.gmail.com","subject":"Re: Possible minor bug in Git","fromName":"Angelo Melonas","fromEmail":"angelomelonas@gmail.com","sentAt":"2019-01-31T07:29:28Z","receivedAt":"2019-01-31T07:29:41Z","isPatch":false,"sender":{"key":"angelomelonas@gmail.com","avatar":null},"body":"Just to clarify, I made a mistake above. Instead of \"untracked\", I\nmeant \"unstaged\".\nI apologise for the confusion.\n\nOn Thu, Jan 31, 2019 at 9:01 AM Angelo Melonas <angelomelonas@gmail.com> wrote:\n>\n> Good day,\n>\n> I found a potential bug in Git for Windows. The bug can be reproduced\n> as follows:\n>\n> 1. Modify a file so that it shows up as \"untracked\" when executing the\n> \"git status\" command.\n> 2. Attempt to \"git add\" the file, but change the case of a single\n> letter. The command executes but no warning or error is displayed.\n> 3. Execute \"git status\" again and it still shows the file as \"untracked\".\n>\n> Please let me know if I am mistaken. I also have a screenshot\n> demonstrating the \"bug\" which I cannot attach to this email, but which\n> can be requested.\n>\n> Have a great day.\n>\n> Kind regards,\n> Angelo Melonas\n"},{"id":"368263","messageId":"20190131203447.aovalz2vzsjpdjdv@tb-raspi4","threadId":"50367","inReplyTo":"CAHYHVP+Dvbq_aOMy1_Kq0LHJsd4r+4GiP3N3R4A9ouAoJ4gw9g@mail.gmail.com","subject":"Re: Possible minor bug in Git","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2019-01-31T20:34:47Z","receivedAt":"2019-01-31T20:34:52Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Thu, Jan 31, 2019 at 09:29:28AM +0200, Angelo Melonas wrote:\n> Just to clarify, I made a mistake above. Instead of \"untracked\", I\n> meant \"unstaged\".\n> I apologise for the confusion.\n>\n> On Thu, Jan 31, 2019 at 9:01 AM Angelo Melonas <angelomelonas@gmail.com> wrote:\n> >\n> > Good day,\n> >\n> > I found a potential bug in Git for Windows. The bug can be reproduced\n> > as follows:\n> >\n> > 1. Modify a file so that it shows up as \"untracked\" when executing the\n> > \"git status\" command.\n> > 2. Attempt to \"git add\" the file, but change the case of a single\n> > letter. The command executes but no warning or error is displayed.\n> > 3. Execute \"git status\" again and it still shows the file as \"untracked\".\n> >\n> > Please let me know if I am mistaken. I also have a screenshot\n> > demonstrating the \"bug\" which I cannot attach to this email, but which\n> > can be requested.\n> >\n> > Have a great day.\n> >\n> > Kind regards,\n> > Angelo Melonas\n\nSee the example below, Git tracks AA.txt, so you must run\ngit add AA.txt\n\nAfter a commit, you can tell Git that the file was renamed:\ngit mv AA.txt Aa.txt\n(and then a commit)\n\n\n\n------------------------------\n\nuser@mac:/tmp/tt2> git init\nInitialized empty Git repository in /private/tmp/tt2/.git/\nuser@mac:/tmp/tt2> echo AAA > AA.txt\nuser@mac:/tmp/tt2> git add AA.txt\nuser@mac:/tmp/tt2> git commit -m AA.txt\n[master (root-commit) f102760] AA.txt\n 1 file changed, 1 insertion(+)\n  create mode 100644 AA.txt\n  user@mac:/tmp/tt2> echo BB >AA.txt\n  user@mac:/tmp/tt2> mv AA.txt  Aa.txt\n  user@mac:/tmp/tt2> git status\n  On branch master\n  Changes not staged for commit:\n    (use \"git add <file>...\" to update what will be committed)\n      (use \"git checkout -- <file>...\" to discard changes in working directory)\n\n        modified:   AA.txt\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\nuser@mac:/tmp/tt2> git add AA.txt\nuser@mac:/tmp/tt2> git status\nOn branch master\nChanges to be committed:\n  (use \"git reset HEAD <file>...\" to unstage)\n\n        modified:   AA.txt\n\nuser@mac:/tmp/tt2>\n"},{"id":"368309","messageId":"CAHYHVPJdbEOPaAoyAhOtJ+wkeXZdowAVqe1Tp_=LOKzuuzA+wQ@mail.gmail.com","threadId":"50367","inReplyTo":"20190131203447.aovalz2vzsjpdjdv@tb-raspi4","subject":"Re: Possible minor bug in Git","fromName":"Angelo Melonas","fromEmail":"angelomelonas@gmail.com","sentAt":"2019-02-01T08:02:50Z","receivedAt":"2019-02-01T08:03:03Z","isPatch":false,"sender":{"key":"angelomelonas@gmail.com","avatar":null},"body":"Hi Torsten,\n\nThank you so much for getting back to me.\n\nUnfortunately, I believe there is a misunderstanding, as I may have\nexplained what I found to be a possible bug incorrectly.\nThe file that is originally added (and then later modified) is never\nrenamed or moved.\nAs you will see below, when a user attempts to add a file, but with\nthe incorrect case, the Git CLI responds the same way it would if a\nfile was correctly added (i.e., by displaying nothing).\nHowever, in the above case, when you enter \"git status\", you find that\nthe file was never actually added, and remains unstaged.\nA possible solution to this can be a simple error message similar to\nattempting to add a file with its name misspelt.\n\nUsing your example, I have illustrated this in the text below:\n\n    C:\\Example>git init\n    Initialized empty Git repository in C:/Example/.git/\n\n    C:\\Example>echo AAA > AA.txt\n\n    C:\\Example>git add AA.txt\n\n    C:\\Example>git commit -m AA.txt\n    [master (root-commit) d550af0] AA.txt\n     1 file changed, 1 insertion(+)\n     create mode 100644 AA.txt\n\n    C:\\Example>echo BB > AA.txt\n\n    C:\\Example>git status\n    On branch master\n    Changes not staged for commit:\n      (use \"git add <file>...\" to update what will be committed)\n      (use \"git checkout -- <file>...\" to discard changes in working directory)\n\n            modified:   AA.txt\n\n    no changes added to commit (use \"git add\" and/or \"git commit -a\")\n\n    C:\\Example>git add Aa.txt\n\n    C:\\Example>git status\n    On branch master\n    Changes not staged for commit:\n      (use \"git add <file>...\" to update what will be committed)\n      (use \"git checkout -- <file>...\" to discard changes in working directory)\n\n            modified:   AA.txt\n\n    no changes added to commit (use \"git add\" and/or \"git commit -a\")\n\n    C:\\Example>git add A.txt\n    fatal: pathspec 'A.txt' did not match any files\n\n    C:\\Example>git add AA.txt\n\n    C:\\Example>git status\n    On branch master\n    Changes to be committed:\n      (use \"git reset HEAD <file>...\" to unstage)\n\n            modified:   AA.txt\n\nI am looking forward to hearing from you again.\n\nKind regards,\nAngelo Melonas\n\nOn Thu, Jan 31, 2019 at 10:34 PM Torsten Bögershausen <tboegi@web.de> wrote:\n>\n> On Thu, Jan 31, 2019 at 09:29:28AM +0200, Angelo Melonas wrote:\n> > Just to clarify, I made a mistake above. Instead of \"untracked\", I\n> > meant \"unstaged\".\n> > I apologise for the confusion.\n> >\n> > On Thu, Jan 31, 2019 at 9:01 AM Angelo Melonas <angelomelonas@gmail.com> wrote:\n> > >\n> > > Good day,\n> > >\n> > > I found a potential bug in Git for Windows. The bug can be reproduced\n> > > as follows:\n> > >\n> > > 1. Modify a file so that it shows up as \"untracked\" when executing the\n> > > \"git status\" command.\n> > > 2. Attempt to \"git add\" the file, but change the case of a single\n> > > letter. The command executes but no warning or error is displayed.\n> > > 3. Execute \"git status\" again and it still shows the file as \"untracked\".\n> > >\n> > > Please let me know if I am mistaken. I also have a screenshot\n> > > demonstrating the \"bug\" which I cannot attach to this email, but which\n> > > can be requested.\n> > >\n> > > Have a great day.\n> > >\n> > > Kind regards,\n> > > Angelo Melonas\n>\n> See the example below, Git tracks AA.txt, so you must run\n> git add AA.txt\n>\n> After a commit, you can tell Git that the file was renamed:\n> git mv AA.txt Aa.txt\n> (and then a commit)\n>\n>\n>\n> ------------------------------\n>\n> user@mac:/tmp/tt2> git init\n> Initialized empty Git repository in /private/tmp/tt2/.git/\n> user@mac:/tmp/tt2> echo AAA > AA.txt\n> user@mac:/tmp/tt2> git add AA.txt\n> user@mac:/tmp/tt2> git commit -m AA.txt\n> [master (root-commit) f102760] AA.txt\n>  1 file changed, 1 insertion(+)\n>   create mode 100644 AA.txt\n>   user@mac:/tmp/tt2> echo BB >AA.txt\n>   user@mac:/tmp/tt2> mv AA.txt  Aa.txt\n>   user@mac:/tmp/tt2> git status\n>   On branch master\n>   Changes not staged for commit:\n>     (use \"git add <file>...\" to update what will be committed)\n>       (use \"git checkout -- <file>...\" to discard changes in working directory)\n>\n>         modified:   AA.txt\n>\n> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n> user@mac:/tmp/tt2> git add AA.txt\n> user@mac:/tmp/tt2> git status\n> On branch master\n> Changes to be committed:\n>   (use \"git reset HEAD <file>...\" to unstage)\n>\n>         modified:   AA.txt\n>\n> user@mac:/tmp/tt2>\n"},{"id":"368399","messageId":"20190202063828.4kjtdmrsm7g4eyg3@tb-raspi4","threadId":"50367","inReplyTo":"CAHYHVPJdbEOPaAoyAhOtJ+wkeXZdowAVqe1Tp_=LOKzuuzA+wQ@mail.gmail.com","subject":"Re: Possible minor bug in Git","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2019-02-02T06:38:28Z","receivedAt":"2019-02-02T06:38:34Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Fri, Feb 01, 2019 at 10:02:50AM +0200, Angelo Melonas wrote:\n> Hi Torsten,\n>\n> Thank you so much for getting back to me.\n>\n> Unfortunately, I believe there is a misunderstanding, as I may have\n> explained what I found to be a possible bug incorrectly.\n> The file that is originally added (and then later modified) is never\n> renamed or moved.\n> As you will see below, when a user attempts to add a file, but with\n> the incorrect case, the Git CLI responds the same way it would if a\n> file was correctly added (i.e., by displaying nothing).\n> However, in the above case, when you enter \"git status\", you find that\n> the file was never actually added, and remains unstaged.\n> A possible solution to this can be a simple error message similar to\n> attempting to add a file with its name misspelt.\n>\n> Using your example, I have illustrated this in the text below:\n>\n>     C:\\Example>git init\n>     Initialized empty Git repository in C:/Example/.git/\n>\n>     C:\\Example>echo AAA > AA.txt\n>\n>     C:\\Example>git add AA.txt\n>\n>     C:\\Example>git commit -m AA.txt\n>     [master (root-commit) d550af0] AA.txt\n>      1 file changed, 1 insertion(+)\n>      create mode 100644 AA.txt\n>\n>     C:\\Example>echo BB > AA.txt\n>\n>     C:\\Example>git status\n>     On branch master\n>     Changes not staged for commit:\n>       (use \"git add <file>...\" to update what will be committed)\n>       (use \"git checkout -- <file>...\" to discard changes in working directory)\n>\n>             modified:   AA.txt\n>\n>     no changes added to commit (use \"git add\" and/or \"git commit -a\")\n>\n>     C:\\Example>git add Aa.txt\n>\n>     C:\\Example>git status\n>     On branch master\n>     Changes not staged for commit:\n>       (use \"git add <file>...\" to update what will be committed)\n>       (use \"git checkout -- <file>...\" to discard changes in working directory)\n>\n>             modified:   AA.txt\n>\n>     no changes added to commit (use \"git add\" and/or \"git commit -a\")\n>\n>     C:\\Example>git add A.txt\n>     fatal: pathspec 'A.txt' did not match any files\n>\n>     C:\\Example>git add AA.txt\n>\n>     C:\\Example>git status\n>     On branch master\n>     Changes to be committed:\n>       (use \"git reset HEAD <file>...\" to unstage)\n>\n>             modified:   AA.txt\n>\n> I am looking forward to hearing from you again.\n>\n> Kind regards,\n> Angelo Melonas\n>\n\nActually yes, you can call this a minor bug.\n\nDoes anybody want to work on it ?\nMay be as a first-time-Git contribution ?\n\n\n"},{"id":"368648","messageId":"20190206221759.338-1-g@evil.localdomain","threadId":"50367","inReplyTo":"20190202063828.4kjtdmrsm7g4eyg3@tb-raspi4","subject":"Re: Possible minor bug in Git","fromName":"Giuseppe Crinò","fromEmail":"giuscri@gmail.com","sentAt":"2019-02-06T22:17:59Z","receivedAt":"2019-02-06T22:18:07Z","isPatch":false,"sender":{"key":"giuscri@gmail.com","avatar":"https://gravatar.com/avatar/0d6b46f6496321ee3646c8712de0b475e225f393a8c72d2c2385d7820b74dd90?d=mp&s=160"},"body":"I wanted to have a look at the bug, and I can correctly reproduce it using version 2.20.1.windows.1.\n\nTo start to even think of fixing this bug I need to build the source for Windows, but I got lost on how to do that.\n\nIs it correct that I should cross-compile from a POSIX system (GNU/Linux), using x86_64-w64-mingw32-gcc and Gnulib to produce a static executable?\n\nAm I missing something? How does people here build for Windows?\n\nGiuseppe\n"},{"id":"368725","messageId":"nycvar.QRO.7.76.6.1902072040360.41@tvgsbejvaqbjf.bet","threadId":"50367","inReplyTo":"20190206221759.338-1-g@evil.localdomain","subject":"Re: Possible minor bug in Git","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-02-07T19:41:00Z","receivedAt":"2019-02-07T19:41:03Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Giuseppe,\n\nOn Wed, 6 Feb 2019, Giuseppe Crinò wrote:\n\n> I wanted to have a look at the bug, and I can correctly reproduce it using version 2.20.1.windows.1.\n> \n> To start to even think of fixing this bug I need to build the source for Windows, but I got lost on how to do that.\n\nDoes this help?\n\nhttps://github.com/git-for-windows/git/wiki/Building-Git\n\nCiao,\nJohannes\n\n> \n> Is it correct that I should cross-compile from a POSIX system (GNU/Linux), using x86_64-w64-mingw32-gcc and Gnulib to produce a static executable?\n> \n> Am I missing something? How does people here build for Windows?\n> \n> Giuseppe\n> "},{"id":"368844","messageId":"20190208174315.nnljdpbh4nyoxgd7@tb-raspi4","threadId":"50367","inReplyTo":"nycvar.QRO.7.76.6.1902072040360.41@tvgsbejvaqbjf.bet","subject":"Re: Possible minor bug in Git","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2019-02-08T17:43:16Z","receivedAt":"2019-02-08T17:43:22Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Fri, Feb 08, 2019 at 04:18:23PM +0100, Giuseppe Crinò wrote:\n> OK, I successfully built git on Windows (thanks Johannes!) and I'm now able to run it.\n>\n> As of 9f16cdd I can successfully reproduce the bug.\n>\n> Interestingly enough, I can reproduce the bug even for /usr/bin/git running inside Windows Subsystem for Linux. Part of the reason might be that both relies on the same lstat() call... (Note: `stat` inside the WSL is case _insensitive_).\n>\n> Now: what is the expected result for git running inside Windows? Should it die saying \"fatal: pathspec ... did not match any files\"?\n>\n> If that's the case, is the following a valid test case?\n>\n> \tdiff --git a/t/t3700-add.sh b/t/t3700-add.sh\n> \tindex 8ee4fc70ad..fadd7c74f6 100755\n> \t--- a/t/t3700-add.sh\n> \t+++ b/t/t3700-add.sh\n> \t@@ -61,6 +61,11 @@ test_expect_success 'git add: filemode=0 should not get confused by symlink' '\n> \t\ttest_mode_in_index 120000 xfoo2\n> \t '\n>\n> \t+test_expect_success 'git add: pathspec is case-sensitive' '\n> \t+       echo new > file &&\n> \t+       test_must_fail git add File\n> \t+'\n> \t+\n\nIn general, yes.\nThere are 2 comments:\nThis the \"echo\" line should have no ' ' after the '>':\n\n\techo new >file &&\n\nThe other question is,\nif we should move that test case into t0050-filesystem.sh,\nbut that is a matter of taste.\n\ndiff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh\nindex 192c94eccd..b8d6bad97a 100755\n--- a/t/t0050-filesystem.sh\n+++ b/t/t0050-filesystem.sh\n@@ -106,6 +106,11 @@ test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '\n        test \"z$(git cat-file blob :$camel)\" = z1\n\t '\n\n+test_expect_success CASE_INSENSITIVE_FS 'add (with wrong case)' '\n+       git reset --hard initial &&\n+       test_must_fail git add CAMELCASE\n+'\n+\n\n"},{"id":"368931","messageId":"788eefef-f677-f0ce-7e02-dd85b11da78a@iee.org","threadId":"50367","inReplyTo":"nycvar.QRO.7.76.6.1902072040360.41@tvgsbejvaqbjf.bet","subject":"Re: Possible minor bug in Git","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":"2019-02-09T18:19:11Z","receivedAt":"2019-02-09T18:19:15Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"Hi Guiseppe,\n\nOn 07/02/2019 19:41, Johannes Schindelin wrote:\n> Hi Giuseppe,\n>\n> On Wed, 6 Feb 2019, Giuseppe Crinò wrote:\n>\n>> I wanted to have a look at the bug, and I can correctly reproduce it using version 2.20.1.windows.1.\n\nThank you for having a look.\n\nThe root cause of the issues will most probably be use of a case \ninsensitive file system on Windows (and Mac). There is a configuration \nflag `core.ignoreCase` [1] that is normally auto detected that can be \nused to decide when the checks should be done and advice [2] or warnings \ngiven.\n\n\nThere are also similar case issues with branch names should you want to \ngo that far. In any case you should probably at least cover the full \nutf-8 filenames, not just ascii ones.\n\n>>\n>> To start to even think of fixing this bug I need to build the source for Windows, but I got lost on how to do that.\n> Does this help?\n>\n> https://github.com/git-for-windows/git/wiki/Building-Git\n>\n> Ciao,\n> Johannes\n>\n>> Is it correct that I should cross-compile from a POSIX system (GNU/Linux), using x86_64-w64-mingw32-gcc and Gnulib to produce a static executable?\n>>\n>> Am I missing something? How does people here build for Windows?\n>>\n>> Giuseppe\n\n--\n\nPhilip\n\n[1] https://git-scm.com/docs/git-config#git-config-coreignoreCase\n\n[2] https://git-scm.com/docs/git-config#git-config-advice\n\n"},{"id":"368988","messageId":"20190210224607.GA118@evil.localdomain","threadId":"50367","inReplyTo":"788eefef-f677-f0ce-7e02-dd85b11da78a@iee.org","subject":"Re: Possible minor bug in Git","fromName":"Giuseppe Crino'","fromEmail":"giuscri@gmail.com","sentAt":"2019-02-10T22:46:08Z","receivedAt":"2019-02-10T22:47:04Z","isPatch":false,"sender":{"key":"giuscri@gmail.com","avatar":"https://gravatar.com/avatar/0d6b46f6496321ee3646c8712de0b475e225f393a8c72d2c2385d7820b74dd90?d=mp&s=160"},"body":"Setting `true` as the default for GIT_ICASE_PATHSPECS_ENVIRONMENT, when git is built on a Windows system, solves the bug.\n\n\tdiff --git a/pathspec.c b/pathspec.c\n\tindex 12c2b322b3..906cf24e3e 100644\n\t--- a/pathspec.c\n\t+++ b/pathspec.c\n\t@@ -237,7 +237,11 @@ static inline int get_icase_global(void)\n\t\tstatic int icase = -1;\n\n\t\tif (icase < 0)\n\t+       #if defined(GIT_WINDOWS_NATIVE) || defined(__CYGWIN__)\n\t+               icase = git_env_bool(GIT_ICASE_PATHSPECS_ENVIRONMENT, 1);\n\t+       #else\n\t\t\ticase = git_env_bool(GIT_ICASE_PATHSPECS_ENVIRONMENT, 0);\n\t+       #endif\n\n\t\treturn icase;\n\t }\n\nUnfortunately that fix introduces a regression too, tested in t/t3700-add.sh --- `error out when attempting to add ignored ones but add others`.\n\nI already spent some time to understand why, but got no luck: I have to dive deeper into the source code.\n\nIn case I can fix the regression, is changing the default value of that env variable a good solution? Should I change the approach?\n\nLike leveraging core.ignorecase somewhere ...?\n\nOn Sat, Feb 09, 2019 at 06:19:11PM +0000, Philip Oakley wrote:\n> The root cause of the issues will most probably be use of a case insensitive\n> file system on Windows (and Mac). There is a configuration flag\n> `core.ignoreCase` [1] that is normally auto detected that can be used to\n> decide when the checks should be done and advice [2] or warnings given.\n\nThanks,\n\nGiuseppe\n"}]}