Re: [PATCH] t7400: add BSLASHPSPEC prerequisite to 'add with \\ in path'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 29.04.2017 um 02:15 schrieb Ramsay Jones:


On 28/04/17 20:54, Johannes Sixt wrote:
Am 28.04.2017 um 05:09 schrieb Junio C Hamano:
Ramsay Jones <ramsay@xxxxxxxxxxxxxxxxxxxx> writes:

Commit cf9e55f494 ("submodule: prevent backslash expantion in submodule
names", 07-04-2017) added a test which creates a git repository with
some backslash characters in the name. This test cannot work on windows,
since the backslash is used as the directory separator. In order to
suppress this test on cygwin, MinGW and Git for Windows, we add the
BSLASHPSPEC prerequisite. (see also commits 6fd1106aa4 and c51c0da222).

First, let me say that meaning of BSLASHPSPEC was
"keeps backslaches in pathspec arguments" originally,
but it apparently changed meaning since then.

Indeed. I started to give some of the history in the commit message, but
it was nearly 3am, so I punted with the 'see also commits 6fd1106aa4 and
c51c0da222' ... ;-)

t7400.20 does not fail for the MinGW port because the
test case only operates on the file system, but never
checks whether an entry 'sub\with\backslash' is present
in the index.

Ah, OK. I only looked at my (64-bit) MSYS2 build, which fails
exactly the same as cygwin. Hmm, wait, let me just rebuild on
MinGW64 ... indeed it passes (well it passes t7400.20, but it
fails on t7400.11, 61, 63, 87 and 89)!

I don't observe these failures. Are you using a vanila MSYS2 environment? The exact failure modes would be interesting, if you want to hear "Ah, Git for Windows does this and that to make this work". ;)

I assume the test fails right at 'git init' under Cygwin?

Indeed. Also on MSYS2 (exactly as on cygwin):

ramsay@satellite  MSYS $ ./t7400-submodule-basic.sh -i -v

...

ok 19 - submodule add with ./, /.. and // in path

expecting success:
        test_when_finished "rm -rf parent sub\\with\\backslash" &&

        # Initialize a repo with a backslash in its name
        git init sub\\with\\backslash &&
        touch sub\\with\\backslash/empty.file &&
        git -C sub\\with\\backslash add empty.file &&
        git -C sub\\with\\backslash commit -m "Added empty.file" &&

        # Add that repository as a submodule
        git init parent &&
        git -C parent submodule add ../sub\\with\\backslash

fatal: cannot mkdir sub\with\backslash: No such file or directory
not ok 20 - submodule add with \\ in path
#
#               test_when_finished "rm -rf parent sub\\with\\backslash" &&
#
#               # Initialize a repo with a backslash in its name
#               git init sub\\with\\backslash &&
#               touch sub\\with\\backslash/empty.file &&
#               git -C sub\\with\\backslash add empty.file &&
#               git -C sub\\with\\backslash commit -m "Added empty.file" &&
#
#               # Add that repository as a submodule
#               git init parent &&
#               git -C parent submodule add ../sub\\with\\backslash
#
ramsay@satellite  MSYS $

ramsay@satellite  MSYS $ cd trash\ directory.t7400-submodule-basic/

ramsay@satellite  MSYS $ ls
a       addtest/         empty   expect-head   head   head-sha1  untracked
actual  addtest-ignore/  expect  expect-heads  heads  t          z

ramsay@satellite  MSYS $ git init sub\\with\\backslash
fatal: cannot mkdir sub\with\backslash: No such file or directory

ramsay@satellite  MSYS $ mkdir -p sub\\with

OK: git init calls mkdir("sub\\with\\backslash"), which does not create the missing directories automatically. Therefore, this mkdir helps. In the next call, the OS functions behind mkdir simply take the backslashes as directory separators:


ramsay@satellite  MSYS $ git init sub\\with\\backslash
Initialized empty Git repository in /home/ramsay/git/t/trash directory.t7400-submodule-basic/sub/with/backslash/.git/

ramsay@satellite  MSYS $ touch sub\\with\\backslash/empty.file
ramsay@satellite  MSYS $ git -C sub\\with\\backslash add empty.file
ramsay@satellite  MSYS $ git -C sub\\with\\backslash commit -m "Added empty.file"
[master (root-commit) 6fde90b] Added empty.file
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 empty.file

ramsay@satellite  MSYS $ git init parent
Initialized empty Git repository in /home/ramsay/git/t/trash directory.t7400-submodule-basic/parent/.git/

ramsay@satellite  MSYS $ git -C parent submodule add ../sub\\with\\backslash
Cloning into '/home/ramsay/git/t/trash directory.t7400-submodule-basic/parent/sub/with/backslash'...
done.
fatal: Not a git repository: /home/ramsay/git/t/trash directory.t7400-submodule-basic/parent/sub\with\backslash/../.git/modules/sub/with/backslash

MSYS git does not know that the backslash is a directory separator. Hence, it constructs a path with only a single .. component thinking that this walks above sub\with\backslash to end up in parent/; but the underlying OS operation interprets the backslashes as directory separator and ends up in parent/sub\with\. Of coures, no .git directory is at this point, hence the failure.

MinGW git, however, knows about the backslash's meaning and constructs a path containing ../../.. to walk sufficiently high up in the hierarchy and finds the .git directory.

-- Hannes




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]