`git add <<windows 8.3 path to file inside repo>>` results in "fatal: ... is outside repository"
- From
Anthony Sottile <asottile@umich.edu>
- Date
- Mar 10, 2019, 22:41 UTC
- Message-ID
- <CA+dzEBkkbQj0rCjvPfcET2Uvt6fP_v+wQE52ZkAND2Mps08SNQ@mail.gmail.com>
(In case 8.3 filename isn't a familiar term): https://en.wikipedia.org/wiki/8.3_filename
This is distilled down from an actual issue to a minimal testcase.
The original failure involves an automated test while running on azure pipelines: https://asottile.visualstudio.com/asottile/_build/results?buildId=254
I'm using git on windows
>git --version
git version 2.21.0.windows.1
Here's a minimal case:
git init longname-repo cd longname-repo touch f git add ..\longna~1\f
Here's the output:
C:\Users\Anthony\AppData\Local\Temp\t\pre-commit-hooks>git init longname-repo Initialized empty Git repository in C:/Users/Anthony/AppData/Local/Temp/t/pre-commit-hooks/longname-repo/.git/
C:\Users\Anthony\AppData\Local\Temp\t\pre-commit-hooks>cd longname-repo
C:\Users\Anthony\AppData\Local\Temp\t\pre-commit-hooks\longname-repo>touch f
C:\Users\Anthony\AppData\Local\Temp\t\pre-commit-hooks\longname-repo>git add ..\longna~1\f fatal: ..\longna~1\f: '..\longna~1\f' is outside repository
It is however inside the repository:
C:\Users\Anthony\AppData\Local\Temp\t\pre-commit-hooks\longname-repo>python Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.samefile('f', r'..\longna~1\f')True
Anthony