Skip to contentSkip to conversation

git clone does not understand insteadOf URLs

DISCUSSION Gioele Barabucci 5 participants 10 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hello,

it seems that git clone does not understand keywords used insteadOf longer URLs.

    $ git clone remote-repo/ProjectA.git
    fatal repository 'remote-repo/ProjectA.git' does not exist

I suppose that git interprets the argument as a local directory. Git should see if the argument matches one of the known URLs before raising an error.

Regards,

Signature · 1 line
Gioele Barabucci <[email protected]>
#1 lore raw

Why someone should be do something like this ? What is the use case ?

Best regards

2013/5/25, Gioele Barabucci <[email protected]>:

Quoted 21 lines

Hello,

it seems that git clone does not understand keywords used insteadOf longer URLs.

     $ git clone remote-repo/ProjectA.git
     fatal repository 'remote-repo/ProjectA.git' does not exist

I suppose that git interprets the argument as a local directory. Git should see if the argument matches one of the known URLs before raising an error.

Regards,

--
Gioele Barabucci <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Inviato dal mio dispositivo mobile
#2 lore raw

Il 26/05/2013 17:13, Elia Pinto ha scritto:

Quoted 4 lines
Quoted 2 lines
      $ git clone remote-repo/ProjectA.git
      fatal repository 'remote-repo/ProjectA.git' does not exist

Why someone should be do something like this ? What is the use case ?

Simple, I keep all my projects on the same server, so I would like to refer to that server + path using 'remote-repo'.

"git+ssh://git.example.org//users/gioele/projects" insteadOf "remote-repo"

I also helps me when I move all the projects from one path to another in the remote server: I only need to change the path once in ~/.gitconfig.

Please note that git remote add correctly understands 'remote-repo/ProjectA.git'. I was expecting that clone and remote both used the same code to parse paths.

Regards,

Signature · 1 line
Gioele Barabucci <[email protected]>
#3 lore raw
Quoted 4 lines · Gioele Barabucci

Simple, I keep all my projects on the same server, so I would like to refer to that server + path using 'remote-repo'.

"git+ssh://git.example.org//users/gioele/projects" insteadOf "remote-repo"

You can use "remote-repo:" instead.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#4 lore raw

Il 26/05/2013 20:00, Andreas Schwab ha scritto:

Quoted 6 lines
Quoted 4 lines

Simple, I keep all my projects on the same server, so I would like to refer to that server + path using 'remote-repo'.

"git+ssh://git.example.org//users/gioele/projects" insteadOf "remote-repo"

You can use "remote-repo:" instead.

Do you mean I could use "git+ssh://git.example.org//users/gioele/projects" insteadOf "remote-repo:"? Yes, but now I have dozens of repositories already set up in various workstations and I do not want to go and change all of them.

What really bugs me is the fact that git clone and git remote add parse the same path in different ways. Git already has many inconsistencies. This one can be easily ironed out.

Regards,

Signature · 1 line
Gioele Barabucci <[email protected]>
#5 lore raw
Quoted 8 lines · Gioele Barabucci

Il 26/05/2013 20:00, Andreas Schwab ha scritto:

Quoted 6 lines
Quoted 4 lines

Simple, I keep all my projects on the same server, so I would like to refer to that server + path using 'remote-repo'.

"git+ssh://git.example.org//users/gioele/projects" insteadOf "remote-repo"

You can use "remote-repo:" instead.

Quoted 8 lines

Do you mean I could use "git+ssh://git.example.org//users/gioele/projects" insteadOf "remote-repo:"? Yes, but now I have dozens of repositories already set up in various workstations and I do not want to go and change all of them.

What really bugs me is the fact that git clone and git remote add parse the same path in different ways. Git already has many inconsistencies. This one can be easily ironed out.

In what way do you think that git remote add handles the path?

All git remote add does is add a new "remote.<name>.url" entry to the configuration file with the value as given on the command line. The insteadOf mapping will only be applied when you try to fetch from/push to the remote.

#6 lore raw

Il 26/05/2013 20:14, John Keeping ha scritto:

Quoted 5 lines · Gioele Barabucci
Quoted 4 lines

Il 26/05/2013 20:00, Andreas Schwab ha scritto:

Quoted 3 lines
Quoted 3 lines

Simple, I keep all my projects on the same server, so I would like to refer to that server + path using 'remote-repo'.

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"git+ssh://git.example.org//users/gioele/projects" insteadOf "remote-repo"

In what way do you think that git remote add handles the path?

All git remote add does is add a new "remote.<name>.url" entry to the configuration file with the value as given on the command line. The insteadOf mapping will only be applied when you try to fetch from/push to the remote.

Regardless of the implementation of the commands, if I do

mkdir projectA
cd projectA
git init .
git remote add origin remote-repo/projectA.git git pull origin master

I get a working repository. If I do

git clone remote-repo/projectA.git

all I will get is an error.

I do not see any reason (UX-wise) why the two sequences of commands shouldn't work the same when used on the same URL.

Regards,

Signature · 1 line
Gioele Barabucci <[email protected]>
#7 lore raw
Quoted 23 lines · Gioele Barabucci

Il 26/05/2013 20:14, John Keeping ha scritto:

Quoted 5 lines · Gioele Barabucci
Quoted 4 lines

Il 26/05/2013 20:00, Andreas Schwab ha scritto:

Quoted 3 lines
Quoted 3 lines

Simple, I keep all my projects on the same server, so I would like to refer to that server + path using 'remote-repo'.

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"git+ssh://git.example.org//users/gioele/projects" insteadOf "remote-repo"

In what way do you think that git remote add handles the path?

All git remote add does is add a new "remote.<name>.url" entry to the configuration file with the value as given on the command line. The insteadOf mapping will only be applied when you try to fetch from/push to the remote.

Regardless of the implementation of the commands, if I do

mkdir projectA
cd projectA
git init .
git remote add origin remote-repo/projectA.git git pull origin master

Quoted 5 lines

I get a working repository. If I do

git clone remote-repo/projectA.git

all I will get is an error.

So the problem is that "git clone" does not seem to perform normal remote processing if you give it something that looks like a path.

More specifically, it looks like the problem is that if you give clone something that does not contain a colon (':') it considers it to be a local path and dies if that path does not exist. Adding a colon as Andreas suggested makes it look like a remote URL so it will be handled correctly.

#8 lore raw

Il 26/05/2013 21:00, John Keeping ha scritto:

Quoted 8 lines
Quoted 8 lines

Regardless of the implementation of the commands, if I do

mkdir projectA
cd projectA
git init .
git remote add origin remote-repo/projectA.git git pull origin master

Quoted 8 lines
Quoted 5 lines

I get a working repository. If I do

git clone remote-repo/projectA.git

all I will get is an error.

So the problem is that "git clone" does not seem to perform normal remote processing if you give it something that looks like a path.

I understand the problem. In the original email that started this thread I asked for...

Quoted 3 lines

I suppose that git interprets the argument as a local directory. Git should see if the argument matches one of the known URLs before raising an error.

I think all the paths should mean the same in every git command. In this case, checking for insteadOf URLs before failing would solve this problem.

Regards,

Signature · 1 line
Gioele Barabucci <[email protected]>
#9 lore raw
In reply to Andreas Schwab
Quoted 8 lines · Andreas Schwab
Quoted 4 lines · Gioele Barabucci

Simple, I keep all my projects on the same server, so I would like to refer to that server + path using 'remote-repo'.

"git+ssh://git.example.org//users/gioele/projects" insteadOf "remote-repo"

You can use "remote-repo:" instead.

That "with colon" is pretty much how it was designed to be used, but the code did not insist that the insteadof has at least the scheme part, and by mistake allowed something like this

[url "k.org:/pub/scm/git"] insteadOf = g

to be used with "g/foo" to expand to "k.org:/pub/scm/git/foo".

But if "git fetch g/foo" with such a configuration happily goes to "k.org:/pub/scm/git/foo" without problems, then I think it is very reasonable to delay the "is that a local filename?" short-cut "git clone" does and let the insteadof URL expand take place before it.