git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* `git add <<windows 8.3 path to file inside repo>>` results in "fatal: ... is outside repository"
@ 2019-03-10 22:41 Anthony Sottile
  2019-03-11 17:48 ` Johannes Sixt
  0 siblings, 1 reply; 8+ messages in thread
From: Anthony Sottile @ 2019-03-10 22:41 UTC (permalink / raw)
  To: Git Mailing List

(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

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

* Re: `git add <<windows 8.3 path to file inside repo>>` results in "fatal: ... is outside repository"
  2019-03-10 22:41 `git add <<windows 8.3 path to file inside repo>>` results in "fatal: ... is outside repository" Anthony Sottile
@ 2019-03-11 17:48 ` Johannes Sixt
  2019-03-11 17:53   ` Anthony Sottile
  2019-03-11 17:55   ` Torsten Bögershausen
  0 siblings, 2 replies; 8+ messages in thread
From: Johannes Sixt @ 2019-03-11 17:48 UTC (permalink / raw)
  To: Anthony Sottile; +Cc: Git Mailing List

Am 10.03.19 um 23:41 schrieb Anthony Sottile:
> git init longname-repo
> cd longname-repo
> touch f
> git add ..\longna~1\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

This has nothing to do with long vs. short path names. It would report
the same error when you say

  git add ..\longname-repo\f

-- Hannes

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

* Re: `git add <<windows 8.3 path to file inside repo>>` results in "fatal: ... is outside repository"
  2019-03-11 17:48 ` Johannes Sixt
@ 2019-03-11 17:53   ` Anthony Sottile
  2019-03-11 17:55   ` Torsten Bögershausen
  1 sibling, 0 replies; 8+ messages in thread
From: Anthony Sottile @ 2019-03-11 17:53 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Git Mailing List

On Mon, Mar 11, 2019 at 10:48 AM Johannes Sixt <j6t@kdbg.org> wrote:
>
> Am 10.03.19 um 23:41 schrieb Anthony Sottile:
> > git init longname-repo
> > cd longname-repo
> > touch f
> > git add ..\longna~1\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
>
> This has nothing to do with long vs. short path names. It would report
> the same error when you say
>
>   git add ..\longname-repo\f
>
> -- Hannes

Oops, I misreported while trying to minimize my reproduction

Here's an accurate bug report

git properly handles this:

    git add C:\full\path\to\longname-repo\file

When the root of the repo root is `C:\full\path\to\longname-repo`

But it does not handle the equivalent 8.3 path:

    git add C:\full\path\to\longna~1\file

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

* Re: `git add <<windows 8.3 path to file inside repo>>` results in "fatal: ... is outside repository"
  2019-03-11 17:48 ` Johannes Sixt
  2019-03-11 17:53   ` Anthony Sottile
@ 2019-03-11 17:55   ` Torsten Bögershausen
  2019-03-11 18:16     ` Anthony Sottile
  1 sibling, 1 reply; 8+ messages in thread
From: Torsten Bögershausen @ 2019-03-11 17:55 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Anthony Sottile, Git Mailing List

On Mon, Mar 11, 2019 at 06:48:11PM +0100, Johannes Sixt wrote:
> Am 10.03.19 um 23:41 schrieb Anthony Sottile:
> > git init longname-repo
> > cd longname-repo
> > touch f
> > git add ..\longna~1\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
>
> This has nothing to do with long vs. short path names. It would report
> the same error when you say
>
>   git add ..\longname-repo\f
>
> -- Hannes

You can probably do another test:

 mkdir longname-rexxx
 git init longname-repo
 cd longname-repo
 touch f
 git add ..\longna~1\f

And now nobody knows for shure if "longna~1"
is longname-rexxx or longname-repo

It may happen that it is longname-rep at this point in time,
at your machine.
It may happen that it is a complete different directory on another machine,
or even on your machine.
For that reason, to avoid that someone tampers data outside a repo,
"../" (or ..\ under windows) is not accepted by Git.

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

* Re: `git add <<windows 8.3 path to file inside repo>>` results in "fatal: ... is outside repository"
  2019-03-11 17:55   ` Torsten Bögershausen
@ 2019-03-11 18:16     ` Anthony Sottile
  2019-03-11 19:34       ` Jack Adrian Zappa
  0 siblings, 1 reply; 8+ messages in thread
From: Anthony Sottile @ 2019-03-11 18:16 UTC (permalink / raw)
  To: Torsten Bögershausen; +Cc: Johannes Sixt, Git Mailing List

On Mon, Mar 11, 2019 at 10:55 AM Torsten Bögershausen <tboegi@web.de> wrote:
>
> On Mon, Mar 11, 2019 at 06:48:11PM +0100, Johannes Sixt wrote:
> > Am 10.03.19 um 23:41 schrieb Anthony Sottile:
> > > git init longname-repo
> > > cd longname-repo
> > > touch f
> > > git add ..\longna~1\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
> >
> > This has nothing to do with long vs. short path names. It would report
> > the same error when you say
> >
> >   git add ..\longname-repo\f
> >
> > -- Hannes
>
> You can probably do another test:
>
>  mkdir longname-rexxx
>  git init longname-repo
>  cd longname-repo
>  touch f
>  git add ..\longna~1\f
>
> And now nobody knows for shure if "longna~1"
> is longname-rexxx or longname-repo
>
> It may happen that it is longname-rep at this point in time,
> at your machine.
> It may happen that it is a complete different directory on another machine,
> or even on your machine.
> For that reason, to avoid that someone tampers data outside a repo,
> "../" (or ..\ under windows) is not accepted by Git.

the same can be said for `git add /full/path/to/repo/file` as any of
those components could be symlinks.

However that is currently allowed

Note also I've updated my report, it isn't about relative paths any
more but about full paths with 8.3 paths

Note that 8.3 filanames do canonically disambiguate themselves, the
number after the tilde is used to refer to filenames alphabetically

This report is very similar to the change that happened to
disambiguate drive letters in
https://github.com/git/git/commit/d8727b3687c1d249e84be71a581cc1fb0581336a


> Oops, I misreported while trying to minimize my reproduction
>
> Here's an accurate bug report
>
> git properly handles this:
>
>     git add C:\full\path\to\longname-repo\file
>
> When the root of the repo root is `C:\full\path\to\longname-repo`
>
> But it does not handle the equivalent 8.3 path:
>
>     git add C:\full\path\to\longna~1\file

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

* Re: `git add <<windows 8.3 path to file inside repo>>` results in "fatal: ... is outside repository"
  2019-03-11 18:16     ` Anthony Sottile
@ 2019-03-11 19:34       ` Jack Adrian Zappa
  2019-03-11 20:13         ` Anthony Sottile
  2019-03-12 22:49         ` Johannes Schindelin
  0 siblings, 2 replies; 8+ messages in thread
From: Jack Adrian Zappa @ 2019-03-11 19:34 UTC (permalink / raw)
  To: Anthony Sottile
  Cc: Torsten Bögershausen, Johannes Sixt, Git Mailing List

Hey Anthony,

Are you sure that you have 8.3 active on the partition you are using?
IIRC, It is not on by default anymore.  To see, go to a cmd line and
type "dir /x".  If there are any files that exceed the 8.3 format, it
will show those files with two names, the 8.3 name and the long name.

If it is off and you want to turn it on, see
https://support.microsoft.com/en-ca/help/121007/how-to-disable-8-3-file-name-creation-on-ntfs-partitions.
and https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/ff621566(v=ws.11)
for more information.


A

On Mon, Mar 11, 2019 at 2:18 PM Anthony Sottile <asottile@umich.edu> wrote:
>
> On Mon, Mar 11, 2019 at 10:55 AM Torsten Bögershausen <tboegi@web.de> wrote:
> >
> > On Mon, Mar 11, 2019 at 06:48:11PM +0100, Johannes Sixt wrote:
> > > Am 10.03.19 um 23:41 schrieb Anthony Sottile:
> > > > git init longname-repo
> > > > cd longname-repo
> > > > touch f
> > > > git add ..\longna~1\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
> > >
> > > This has nothing to do with long vs. short path names. It would report
> > > the same error when you say
> > >
> > >   git add ..\longname-repo\f
> > >
> > > -- Hannes
> >
> > You can probably do another test:
> >
> >  mkdir longname-rexxx
> >  git init longname-repo
> >  cd longname-repo
> >  touch f
> >  git add ..\longna~1\f
> >
> > And now nobody knows for shure if "longna~1"
> > is longname-rexxx or longname-repo
> >
> > It may happen that it is longname-rep at this point in time,
> > at your machine.
> > It may happen that it is a complete different directory on another machine,
> > or even on your machine.
> > For that reason, to avoid that someone tampers data outside a repo,
> > "../" (or ..\ under windows) is not accepted by Git.
>
> the same can be said for `git add /full/path/to/repo/file` as any of
> those components could be symlinks.
>
> However that is currently allowed
>
> Note also I've updated my report, it isn't about relative paths any
> more but about full paths with 8.3 paths
>
> Note that 8.3 filanames do canonically disambiguate themselves, the
> number after the tilde is used to refer to filenames alphabetically
>
> This report is very similar to the change that happened to
> disambiguate drive letters in
> https://github.com/git/git/commit/d8727b3687c1d249e84be71a581cc1fb0581336a
>
>
> > Oops, I misreported while trying to minimize my reproduction
> >
> > Here's an accurate bug report
> >
> > git properly handles this:
> >
> >     git add C:\full\path\to\longname-repo\file
> >
> > When the root of the repo root is `C:\full\path\to\longname-repo`
> >
> > But it does not handle the equivalent 8.3 path:
> >
> >     git add C:\full\path\to\longna~1\file

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

* Re: `git add <<windows 8.3 path to file inside repo>>` results in "fatal: ... is outside repository"
  2019-03-11 19:34       ` Jack Adrian Zappa
@ 2019-03-11 20:13         ` Anthony Sottile
  2019-03-12 22:49         ` Johannes Schindelin
  1 sibling, 0 replies; 8+ messages in thread
From: Anthony Sottile @ 2019-03-11 20:13 UTC (permalink / raw)
  To: Jack Adrian Zappa
  Cc: Torsten Bögershausen, Johannes Sixt, Git Mailing List

On Mon, Mar 11, 2019 at 12:34 PM Jack Adrian Zappa
<adrianh.bsc@gmail.com> wrote:
>
> Hey Anthony,
>
> Are you sure that you have 8.3 active on the partition you are using?
> IIRC, It is not on by default anymore.  To see, go to a cmd line and
> type "dir /x".  If there are any files that exceed the 8.3 format, it
> will show those files with two names, the 8.3 name and the long name.
>
> If it is off and you want to turn it on, see
> https://support.microsoft.com/en-ca/help/121007/how-to-disable-8-3-file-name-creation-on-ntfs-partitions.
> and https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/ff621566(v=ws.11)
> for more information.
>
>
> A
>

Yes, it appears they are enabled -- see below


C:\Users\IEUser\AppData\Local\Temp\t\longname-repo>git add
C:\Users\IEUser\AppData\Local\Temp\t\longna~1\f
fatal: C:\Users\IEUser\AppData\Local\Temp\t\longna~1\f:
'C:\Users\IEUser\AppData\Local\Temp\t\longna~1\f' is outside
repository

C:\Users\IEUser\AppData\Local\Temp\t\longname-repo>git add
C:\Users\IEUser\AppData\Local\Temp\t\longname-repo\f

C:\Users\IEUser\AppData\Local\Temp\t\longname-repo>dir /x ..
 Volume in drive C has no label.
 Volume Serial Number is 3A97-874F

 Directory of C:\Users\IEUser\AppData\Local\Temp\t

03/11/2019  01:11 PM    <DIR>                       .
03/11/2019  01:11 PM    <DIR>                       ..
03/11/2019  01:11 PM    <DIR>          LONGNA~1     longname-repo
               0 File(s)              0 bytes
               3 Dir(s)  20,063,666,176 bytes free

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

* Re: `git add <<windows 8.3 path to file inside repo>>` results in "fatal: ... is outside repository"
  2019-03-11 19:34       ` Jack Adrian Zappa
  2019-03-11 20:13         ` Anthony Sottile
@ 2019-03-12 22:49         ` Johannes Schindelin
  1 sibling, 0 replies; 8+ messages in thread
From: Johannes Schindelin @ 2019-03-12 22:49 UTC (permalink / raw)
  To: Jack Adrian Zappa
  Cc: Anthony Sottile, Torsten Bögershausen, Johannes Sixt,
	Git Mailing List

Hi Jack,

On Mon, 11 Mar 2019, Jack Adrian Zappa wrote:

> Are you sure that you have 8.3 active on the partition you are using?
> IIRC, It is not on by default anymore.

It is still on by default on system drives (usually C:), but it is
switched off on other drives by default.

Yet another reason not to use 8.3 format (unless this is your file's
canonical name format to begin with).

Ciao,
Johannes

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

end of thread, other threads:[~2019-03-12 22:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-10 22:41 `git add <<windows 8.3 path to file inside repo>>` results in "fatal: ... is outside repository" Anthony Sottile
2019-03-11 17:48 ` Johannes Sixt
2019-03-11 17:53   ` Anthony Sottile
2019-03-11 17:55   ` Torsten Bögershausen
2019-03-11 18:16     ` Anthony Sottile
2019-03-11 19:34       ` Jack Adrian Zappa
2019-03-11 20:13         ` Anthony Sottile
2019-03-12 22:49         ` Johannes Schindelin

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git