"scm:git:file:///" + repo.getAbsolutePath()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

"scm:git:file:///" + repo.getAbsolutePath()

Ilya Basin
Hi.

I'm looking at the commits c7a9910 & 90089a7 in maven-scm. They create an instance of ScmRepository with

    "scm:git:file:///" + repo.getAbsolutePath()

Although the resulting string is further processed, before passed to git, it doesn't conform with the format documented in https://maven.apache.org/scm/git.html :

- Unneeded extra slash on Linux and Mac.
file:////home/blah means //home/blah and we're lucky that double slash doesn't have special meaning there.

- Unneeded extra slash on Windows
Both file:///C: and file://C: work with the Mingw git.

However, there's a serious problem with UNC paths. To be accepted by the Mingw Git, the path can be of three variants:

- file://localhost/c$/...
- 4 slashes: file:////localhost/c$/...
- 5 slashes: file://///localhost/c$/...

Plus, the path must not have backslashes at the beginning:

    C:\>git clone file:///\\localhost/c$/progs/maven/maven-scm/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/target/git_copy checkin-nobranch
    fatal: 'C:/localhost/c$/progs...

This can be remedied by replacing double backslash in the full scm URL that comes from pom.xml. Users shouldn't be obliged to do the replacement with e.g. build-helper:regex-property

So which variant is better? I think that if we ever want to fix SCM-815, then we must choose the one that is compatible with Cygwin, i.e. 4-slashes.

Also, the documented 2-slashes variant must also be recognized and converted to the 4-slashes before passed to git.exe.

As for non-UNC Cygwin paths, I think that we should't try to detect Cygwin. Instead, the users must configure their Cygwin Git to recognize Mingw-style urls:

    git config --global \
      url.file:///cygdrive/c.insteadOf \
      file:///C: file:///C:
   
    git config --global \
      url.file:///cygdrive/c.insteadOf \
      file://C: file://C:

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: "scm:git:file:///" + repo.getAbsolutePath()

michaelo
Am 2018-07-21 um 10:05 schrieb Basin Ilya:

> Hi.
>
> I'm looking at the commits c7a9910 & 90089a7 in maven-scm. They create an instance of ScmRepository with
>
>      "scm:git:file:///" + repo.getAbsolutePath()
>
> Although the resulting string is further processed, before passed to git, it doesn't conform with the format documented in https://maven.apache.org/scm/git.html :
>
> - Unneeded extra slash on Linux and Mac.
> file:////home/blah means //home/blah and we're lucky that double slash doesn't have special meaning there.
>
> - Unneeded extra slash on Windows
> Both file:///C: and file://C: work with the Mingw git.
>
> However, there's a serious problem with UNC paths. To be accepted by the Mingw Git, the path can be of three variants:
>
> - file://localhost/c$/...
> - 4 slashes: file:////localhost/c$/...
> - 5 slashes: file://///localhost/c$/...
>
> Plus, the path must not have backslashes at the beginning:
>
>      C:\>git clone file:///\\localhost/c$/progs/maven/maven-scm/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/target/git_copy checkin-nobranch
>      fatal: 'C:/localhost/c$/progs...
>
> This can be remedied by replacing double backslash in the full scm URL that comes from pom.xml. Users shouldn't be obliged to do the replacement with e.g. build-helper:regex-property
>
> So which variant is better? I think that if we ever want to fix SCM-815, then we must choose the one that is compatible with Cygwin, i.e. 4-slashes.
>
> Also, the documented 2-slashes variant must also be recognized and converted to the 4-slashes before passed to git.exe.
>
> As for non-UNC Cygwin paths, I think that we should't try to detect Cygwin. Instead, the users must configure their Cygwin Git to recognize Mingw-style urls:
>
>      git config --global \
>        url.file:///cygdrive/c.insteadOf \
>        file:///C: file:///C:
>      
>      git config --global \
>        url.file:///cygdrive/c.insteadOf \
>        file://C: file://C:

The entire URI processing is SCM is old and brittle. Many times it does
not adhere to RFC 3986.

I think it needs a compete rewrite not on top of java.net.URI.

Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]