{"thread":{"id":"50707","subject":"`git add <<windows 8.3 path to file inside repo>>` results in \"fatal: ... is outside repository\"","startedAt":"2019-03-10T22:42:03Z","lastAt":"2019-03-12T22:49:43Z","messageCount":8,"participants":["Anthony Sottile","Johannes Sixt","Torsten Bögershausen","Jack Adrian Zappa","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"371087","messageId":"CA+dzEBkkbQj0rCjvPfcET2Uvt6fP_v+wQE52ZkAND2Mps08SNQ@mail.gmail.com","threadId":"50707","inReplyTo":null,"subject":"`git add <<windows 8.3 path to file inside repo>>` results in \"fatal: ... is outside repository\"","fromName":"Anthony Sottile","fromEmail":"asottile@umich.edu","sentAt":"2019-03-10T22:41:51Z","receivedAt":"2019-03-10T22:42:03Z","isPatch":false,"sender":{"key":"asottile@umich.edu","avatar":"https://avatars.githubusercontent.com/u/1810591?v=4"},"body":"(In case 8.3 filename isn't a familiar term):\nhttps://en.wikipedia.org/wiki/8.3_filename\n\nThis is distilled down from an actual issue to a minimal testcase.\n\nThe original failure involves an automated test while running on azure\npipelines: https://asottile.visualstudio.com/asottile/_build/results?buildId=254\n\nI'm using git on windows\n\n>git --version\ngit version 2.21.0.windows.1\n\nHere's a minimal case:\n\ngit init longname-repo\ncd longname-repo\ntouch f\ngit add ..\\longna~1\\f\n\nHere's the output:\n\nC:\\Users\\Anthony\\AppData\\Local\\Temp\\t\\pre-commit-hooks>git init longname-repo\nInitialized empty Git repository in\nC:/Users/Anthony/AppData/Local/Temp/t/pre-commit-hooks/longname-repo/.git/\n\nC:\\Users\\Anthony\\AppData\\Local\\Temp\\t\\pre-commit-hooks>cd longname-repo\n\nC:\\Users\\Anthony\\AppData\\Local\\Temp\\t\\pre-commit-hooks\\longname-repo>touch f\n\nC:\\Users\\Anthony\\AppData\\Local\\Temp\\t\\pre-commit-hooks\\longname-repo>git\nadd ..\\longna~1\\f\nfatal: ..\\longna~1\\f: '..\\longna~1\\f' is outside repository\n\nIt is however inside the repository:\n\nC:\\Users\\Anthony\\AppData\\Local\\Temp\\t\\pre-commit-hooks\\longname-repo>python\nPython 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64\nbit (AMD64)] on win32\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import os\n>>> os.path.samefile('f', r'..\\longna~1\\f')\nTrue\n\nAnthony\n"},{"id":"371169","messageId":"10972e0e-7fe1-437f-efe6-cff82a1205e0@kdbg.org","threadId":"50707","inReplyTo":"CA+dzEBkkbQj0rCjvPfcET2Uvt6fP_v+wQE52ZkAND2Mps08SNQ@mail.gmail.com","subject":"Re: `git add <<windows 8.3 path to file inside repo>>` results in \"fatal: ... is outside repository\"","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2019-03-11T17:48:11Z","receivedAt":"2019-03-11T17:48:17Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 10.03.19 um 23:41 schrieb Anthony Sottile:\n> git init longname-repo\n> cd longname-repo\n> touch f\n> git add ..\\longna~1\\f\n> \n...\n> \n> C:\\Users\\Anthony\\AppData\\Local\\Temp\\t\\pre-commit-hooks\\longname-repo>git\n> add ..\\longna~1\\f\n> fatal: ..\\longna~1\\f: '..\\longna~1\\f' is outside repository\n\nThis has nothing to do with long vs. short path names. It would report\nthe same error when you say\n\n  git add ..\\longname-repo\\f\n\n-- Hannes\n"},{"id":"371170","messageId":"CA+dzEB=EaMoeSac09kj6huuwdk3sOLf7QQHEoghy2B8UoG2eyg@mail.gmail.com","threadId":"50707","inReplyTo":"10972e0e-7fe1-437f-efe6-cff82a1205e0@kdbg.org","subject":"Re: `git add <<windows 8.3 path to file inside repo>>` results in \"fatal: ... is outside repository\"","fromName":"Anthony Sottile","fromEmail":"asottile@umich.edu","sentAt":"2019-03-11T17:53:16Z","receivedAt":"2019-03-11T17:53:32Z","isPatch":false,"sender":{"key":"asottile@umich.edu","avatar":"https://avatars.githubusercontent.com/u/1810591?v=4"},"body":"On Mon, Mar 11, 2019 at 10:48 AM Johannes Sixt <j6t@kdbg.org> wrote:\n>\n> Am 10.03.19 um 23:41 schrieb Anthony Sottile:\n> > git init longname-repo\n> > cd longname-repo\n> > touch f\n> > git add ..\\longna~1\\f\n> >\n> ...\n> >\n> > C:\\Users\\Anthony\\AppData\\Local\\Temp\\t\\pre-commit-hooks\\longname-repo>git\n> > add ..\\longna~1\\f\n> > fatal: ..\\longna~1\\f: '..\\longna~1\\f' is outside repository\n>\n> This has nothing to do with long vs. short path names. It would report\n> the same error when you say\n>\n>   git add ..\\longname-repo\\f\n>\n> -- Hannes\n\nOops, I misreported while trying to minimize my reproduction\n\nHere's an accurate bug report\n\ngit properly handles this:\n\n    git add C:\\full\\path\\to\\longname-repo\\file\n\nWhen the root of the repo root is `C:\\full\\path\\to\\longname-repo`\n\nBut it does not handle the equivalent 8.3 path:\n\n    git add C:\\full\\path\\to\\longna~1\\file\n"},{"id":"371172","messageId":"20190311175519.6lbppv5u44w2u4sj@tb-raspi4","threadId":"50707","inReplyTo":"10972e0e-7fe1-437f-efe6-cff82a1205e0@kdbg.org","subject":"Re: `git add <<windows 8.3 path to file inside repo>>` results in \"fatal: ... is outside repository\"","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2019-03-11T17:55:19Z","receivedAt":"2019-03-11T17:55:28Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Mon, Mar 11, 2019 at 06:48:11PM +0100, Johannes Sixt wrote:\n> Am 10.03.19 um 23:41 schrieb Anthony Sottile:\n> > git init longname-repo\n> > cd longname-repo\n> > touch f\n> > git add ..\\longna~1\\f\n> >\n> ...\n> >\n> > C:\\Users\\Anthony\\AppData\\Local\\Temp\\t\\pre-commit-hooks\\longname-repo>git\n> > add ..\\longna~1\\f\n> > fatal: ..\\longna~1\\f: '..\\longna~1\\f' is outside repository\n>\n> This has nothing to do with long vs. short path names. It would report\n> the same error when you say\n>\n>   git add ..\\longname-repo\\f\n>\n> -- Hannes\n\nYou can probably do another test:\n\n mkdir longname-rexxx\n git init longname-repo\n cd longname-repo\n touch f\n git add ..\\longna~1\\f\n\nAnd now nobody knows for shure if \"longna~1\"\nis longname-rexxx or longname-repo\n\nIt may happen that it is longname-rep at this point in time,\nat your machine.\nIt may happen that it is a complete different directory on another machine,\nor even on your machine.\nFor that reason, to avoid that someone tampers data outside a repo,\n\"../\" (or ..\\ under windows) is not accepted by Git.\n"},{"id":"371174","messageId":"CA+dzEBm7fdrncnd_7tDu-q047qxt3CsHVQna3GRMagJetisQeA@mail.gmail.com","threadId":"50707","inReplyTo":"20190311175519.6lbppv5u44w2u4sj@tb-raspi4","subject":"Re: `git add <<windows 8.3 path to file inside repo>>` results in \"fatal: ... is outside repository\"","fromName":"Anthony Sottile","fromEmail":"asottile@umich.edu","sentAt":"2019-03-11T18:16:32Z","receivedAt":"2019-03-11T18:16:46Z","isPatch":false,"sender":{"key":"asottile@umich.edu","avatar":"https://avatars.githubusercontent.com/u/1810591?v=4"},"body":"On Mon, Mar 11, 2019 at 10:55 AM Torsten Bögershausen <tboegi@web.de> wrote:\n>\n> On Mon, Mar 11, 2019 at 06:48:11PM +0100, Johannes Sixt wrote:\n> > Am 10.03.19 um 23:41 schrieb Anthony Sottile:\n> > > git init longname-repo\n> > > cd longname-repo\n> > > touch f\n> > > git add ..\\longna~1\\f\n> > >\n> > ...\n> > >\n> > > C:\\Users\\Anthony\\AppData\\Local\\Temp\\t\\pre-commit-hooks\\longname-repo>git\n> > > add ..\\longna~1\\f\n> > > fatal: ..\\longna~1\\f: '..\\longna~1\\f' is outside repository\n> >\n> > This has nothing to do with long vs. short path names. It would report\n> > the same error when you say\n> >\n> >   git add ..\\longname-repo\\f\n> >\n> > -- Hannes\n>\n> You can probably do another test:\n>\n>  mkdir longname-rexxx\n>  git init longname-repo\n>  cd longname-repo\n>  touch f\n>  git add ..\\longna~1\\f\n>\n> And now nobody knows for shure if \"longna~1\"\n> is longname-rexxx or longname-repo\n>\n> It may happen that it is longname-rep at this point in time,\n> at your machine.\n> It may happen that it is a complete different directory on another machine,\n> or even on your machine.\n> For that reason, to avoid that someone tampers data outside a repo,\n> \"../\" (or ..\\ under windows) is not accepted by Git.\n\nthe same can be said for `git add /full/path/to/repo/file` as any of\nthose components could be symlinks.\n\nHowever that is currently allowed\n\nNote also I've updated my report, it isn't about relative paths any\nmore but about full paths with 8.3 paths\n\nNote that 8.3 filanames do canonically disambiguate themselves, the\nnumber after the tilde is used to refer to filenames alphabetically\n\nThis report is very similar to the change that happened to\ndisambiguate drive letters in\nhttps://github.com/git/git/commit/d8727b3687c1d249e84be71a581cc1fb0581336a\n\n\n> Oops, I misreported while trying to minimize my reproduction\n>\n> Here's an accurate bug report\n>\n> git properly handles this:\n>\n>     git add C:\\full\\path\\to\\longname-repo\\file\n>\n> When the root of the repo root is `C:\\full\\path\\to\\longname-repo`\n>\n> But it does not handle the equivalent 8.3 path:\n>\n>     git add C:\\full\\path\\to\\longna~1\\file\n"},{"id":"371182","messageId":"CAKepmajVk27nHAzbuHitowyo11HvqSNfwfcg3kOp9DXDLe8FOA@mail.gmail.com","threadId":"50707","inReplyTo":"CA+dzEBm7fdrncnd_7tDu-q047qxt3CsHVQna3GRMagJetisQeA@mail.gmail.com","subject":"Re: `git add <<windows 8.3 path to file inside repo>>` results in \"fatal: ... is outside repository\"","fromName":"Jack Adrian Zappa","fromEmail":"adrianh.bsc@gmail.com","sentAt":"2019-03-11T19:34:03Z","receivedAt":"2019-03-11T19:34:16Z","isPatch":false,"sender":{"key":"adrianh.bsc@gmail.com","avatar":null},"body":"Hey Anthony,\n\nAre you sure that you have 8.3 active on the partition you are using?\nIIRC, It is not on by default anymore.  To see, go to a cmd line and\ntype \"dir /x\".  If there are any files that exceed the 8.3 format, it\nwill show those files with two names, the 8.3 name and the long name.\n\nIf it is off and you want to turn it on, see\nhttps://support.microsoft.com/en-ca/help/121007/how-to-disable-8-3-file-name-creation-on-ntfs-partitions.\nand https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/ff621566(v=ws.11)\nfor more information.\n\n\nA\n\nOn Mon, Mar 11, 2019 at 2:18 PM Anthony Sottile <asottile@umich.edu> wrote:\n>\n> On Mon, Mar 11, 2019 at 10:55 AM Torsten Bögershausen <tboegi@web.de> wrote:\n> >\n> > On Mon, Mar 11, 2019 at 06:48:11PM +0100, Johannes Sixt wrote:\n> > > Am 10.03.19 um 23:41 schrieb Anthony Sottile:\n> > > > git init longname-repo\n> > > > cd longname-repo\n> > > > touch f\n> > > > git add ..\\longna~1\\f\n> > > >\n> > > ...\n> > > >\n> > > > C:\\Users\\Anthony\\AppData\\Local\\Temp\\t\\pre-commit-hooks\\longname-repo>git\n> > > > add ..\\longna~1\\f\n> > > > fatal: ..\\longna~1\\f: '..\\longna~1\\f' is outside repository\n> > >\n> > > This has nothing to do with long vs. short path names. It would report\n> > > the same error when you say\n> > >\n> > >   git add ..\\longname-repo\\f\n> > >\n> > > -- Hannes\n> >\n> > You can probably do another test:\n> >\n> >  mkdir longname-rexxx\n> >  git init longname-repo\n> >  cd longname-repo\n> >  touch f\n> >  git add ..\\longna~1\\f\n> >\n> > And now nobody knows for shure if \"longna~1\"\n> > is longname-rexxx or longname-repo\n> >\n> > It may happen that it is longname-rep at this point in time,\n> > at your machine.\n> > It may happen that it is a complete different directory on another machine,\n> > or even on your machine.\n> > For that reason, to avoid that someone tampers data outside a repo,\n> > \"../\" (or ..\\ under windows) is not accepted by Git.\n>\n> the same can be said for `git add /full/path/to/repo/file` as any of\n> those components could be symlinks.\n>\n> However that is currently allowed\n>\n> Note also I've updated my report, it isn't about relative paths any\n> more but about full paths with 8.3 paths\n>\n> Note that 8.3 filanames do canonically disambiguate themselves, the\n> number after the tilde is used to refer to filenames alphabetically\n>\n> This report is very similar to the change that happened to\n> disambiguate drive letters in\n> https://github.com/git/git/commit/d8727b3687c1d249e84be71a581cc1fb0581336a\n>\n>\n> > Oops, I misreported while trying to minimize my reproduction\n> >\n> > Here's an accurate bug report\n> >\n> > git properly handles this:\n> >\n> >     git add C:\\full\\path\\to\\longname-repo\\file\n> >\n> > When the root of the repo root is `C:\\full\\path\\to\\longname-repo`\n> >\n> > But it does not handle the equivalent 8.3 path:\n> >\n> >     git add C:\\full\\path\\to\\longna~1\\file\n"},{"id":"371189","messageId":"CA+dzEB=oKhd5O7bhWLNvvYM9eyht7SO1LkY5Sy=tEFhCCZzfDQ@mail.gmail.com","threadId":"50707","inReplyTo":"CAKepmajVk27nHAzbuHitowyo11HvqSNfwfcg3kOp9DXDLe8FOA@mail.gmail.com","subject":"Re: `git add <<windows 8.3 path to file inside repo>>` results in \"fatal: ... is outside repository\"","fromName":"Anthony Sottile","fromEmail":"asottile@umich.edu","sentAt":"2019-03-11T20:13:14Z","receivedAt":"2019-03-11T20:13:30Z","isPatch":false,"sender":{"key":"asottile@umich.edu","avatar":"https://avatars.githubusercontent.com/u/1810591?v=4"},"body":"On Mon, Mar 11, 2019 at 12:34 PM Jack Adrian Zappa\n<adrianh.bsc@gmail.com> wrote:\n>\n> Hey Anthony,\n>\n> Are you sure that you have 8.3 active on the partition you are using?\n> IIRC, It is not on by default anymore.  To see, go to a cmd line and\n> type \"dir /x\".  If there are any files that exceed the 8.3 format, it\n> will show those files with two names, the 8.3 name and the long name.\n>\n> If it is off and you want to turn it on, see\n> https://support.microsoft.com/en-ca/help/121007/how-to-disable-8-3-file-name-creation-on-ntfs-partitions.\n> and https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/ff621566(v=ws.11)\n> for more information.\n>\n>\n> A\n>\n\nYes, it appears they are enabled -- see below\n\n\nC:\\Users\\IEUser\\AppData\\Local\\Temp\\t\\longname-repo>git add\nC:\\Users\\IEUser\\AppData\\Local\\Temp\\t\\longna~1\\f\nfatal: C:\\Users\\IEUser\\AppData\\Local\\Temp\\t\\longna~1\\f:\n'C:\\Users\\IEUser\\AppData\\Local\\Temp\\t\\longna~1\\f' is outside\nrepository\n\nC:\\Users\\IEUser\\AppData\\Local\\Temp\\t\\longname-repo>git add\nC:\\Users\\IEUser\\AppData\\Local\\Temp\\t\\longname-repo\\f\n\nC:\\Users\\IEUser\\AppData\\Local\\Temp\\t\\longname-repo>dir /x ..\n Volume in drive C has no label.\n Volume Serial Number is 3A97-874F\n\n Directory of C:\\Users\\IEUser\\AppData\\Local\\Temp\\t\n\n03/11/2019  01:11 PM    <DIR>                       .\n03/11/2019  01:11 PM    <DIR>                       ..\n03/11/2019  01:11 PM    <DIR>          LONGNA~1     longname-repo\n               0 File(s)              0 bytes\n               3 Dir(s)  20,063,666,176 bytes free\n"},{"id":"371306","messageId":"nycvar.QRO.7.76.6.1903122347250.41@tvgsbejvaqbjf.bet","threadId":"50707","inReplyTo":"CAKepmajVk27nHAzbuHitowyo11HvqSNfwfcg3kOp9DXDLe8FOA@mail.gmail.com","subject":"Re: `git add <<windows 8.3 path to file inside repo>>` results in \"fatal: ... is outside repository\"","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-03-12T22:49:17Z","receivedAt":"2019-03-12T22:49:43Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Jack,\n\nOn Mon, 11 Mar 2019, Jack Adrian Zappa wrote:\n\n> Are you sure that you have 8.3 active on the partition you are using?\n> IIRC, It is not on by default anymore.\n\nIt is still on by default on system drives (usually C:), but it is\nswitched off on other drives by default.\n\nYet another reason not to use 8.3 format (unless this is your file's\ncanonical name format to begin with).\n\nCiao,\nJohannes\n"}]}