# fast-import should fail on invalid unsupported paths

3 messages from 2019-03-18 to 2023-04-19. Participants: Björn Kautler, Jeff King.
Thread: https://gitlist.dev/t/50773

## Björn Kautler, 2019-03-18 17:28

Subject: fast-import should fail on invalid unsupported paths
Message-ID: <CAKChYSo9x5k0Ly2CNs5tbZ+jMdxBmDLZ9gm_645pwXZsCQ4ySg@mail.gmail.com>
URL: https://gitlist.dev/e/CAKChYSo9x5k0Ly2CNs5tbZ%2BjMdxBmDLZ9gm_645pwXZsCQ4ySg%40mail.gmail.com

```
Hi,

with this simple recipe, you get a non-usable repository:

mkdir foo
cd foo
git init --bare repo
cd repo
git fast-import <<"EOM"
commit refs/heads/master
committer <foo@bar.baz> 0 +0000
data 3
foo
M 644 inline foo/.git/bar
data 3
baz
EOM
cd ..
git clone repo worktree

This actually happened when a user tried to port an SVN repository to
a Git repository and had ".git" paths in the SVN repository.
Using KDEs svn2git utility fast-import accepted the invalid path, but
then when trying to checkout during the clone operation, you get the
error message

Cloning into 'worktree'...
done.
error: Invalid path 'foo/.git/bar'

and the worktree stays empty.

I think fast-import should refuse to import paths Git cannot handle
properly later on, so that the migration fails early and the frontend
that generates the fast-import stream can be fixed / configured to not
include such invalid paths.

Regards
Björn

```

## Jeff King, 2019-03-18 21:17

Subject: Re: fast-import should fail on invalid unsupported paths
Message-ID: <20190318211737.GC29661@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20190318211737.GC29661%40sigill.intra.peff.net
In-Reply-To: <CAKChYSo9x5k0Ly2CNs5tbZ+jMdxBmDLZ9gm_645pwXZsCQ4ySg@mail.gmail.com>

```
On Mon, Mar 18, 2019 at 06:28:16PM +0100, Björn Kautler wrote:

> I think fast-import should refuse to import paths Git cannot handle
> properly later on, so that the migration fails early and the frontend
> that generates the fast-import stream can be fixed / configured to not
> include such invalid paths.

Yeah, that seems quite sensible to me[1].

If you (or anybody else) are interested in working on this, I suspect
the answer is to just sprinkle some calls to verify_path() in the right
spots. Probably in fast-import.c:file_change_m(), etc.

-Peff

[1] Stretching to think of a way this might backfire, I guess somebody
    could be using Git as an intermediate format to then convert to
    another system. But that seems terribly obscure, and at most I think
    we should give that case an escape hatch to disable the check; it
    should definitely be on by default.

```

## Björn Kautler, 2023-04-14 11:54

Subject: Re: fast-import should fail on invalid unsupported paths
Message-ID: <CAKChYSonyAw9Gr+vxDsCr4dDE0hvc9ZM6+spJo19h85R357Qkw@mail.gmail.com>
URL: https://gitlist.dev/e/CAKChYSonyAw9Gr%2BvxDsCr4dDE0hvc9ZM6%2BspJo19h85R357Qkw%40mail.gmail.com
In-Reply-To: <20190318211737.GC29661@sigill.intra.peff.net>

```
Hi,

I just want to note that this is still reproducible using 2.40.0. :-)

Regards
Björn

```
