-
Notifications
You must be signed in to change notification settings - Fork 160
Prepare Git's test suite for symbolic link support on Windows #2009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
2d32983
b97afa9
96e279f
9639e04
3db0599
b8a357f
b6dd95a
95efb6b
aed0eb1
e04cf02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -425,7 +425,11 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' ' | |
| git init --separate-git-dir ../realgitdir | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> The test case 're-init to move gitdir symlink' wants to compare the
> contents of `newdir/.git`, which is a symbolic link pointing to a file.
> However, `git diff --no-index`, which is used by `test_cmp` on Windows,
> does not resolve symlinks; It shows the symlink _target_ instead (with a
> file mode of 120000). That is totally unexpected by the test case, which
> as a consequence fails, meaning that it's a bug in the test case itself.
It is dubious if it is a bug in this particular test case, or
test_cmp implementation that uses "git diff --no-index", though.
Either way, when test_cmp here does not do "diff", the test would
fail, so you are correct to notice that this piece of code needs to
be patched in some way. I do not think not comparing is the right
solution, though. Would there be a better option than completely
punting on the comparison? Something silly like:
> + case "$GIT_TEST_CMP" in
> + # git diff --no-index does not resolve symlinks
> + *--no-index*) cmp expected newdir/.git ;;
> + *) test_cmp expected newdir/.git ;;
> + esac &&
perhaps?
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> t/t0001-init.sh | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index 618da080dc..2f38e09b58 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -425,7 +425,10 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
> git init --separate-git-dir ../realgitdir
> ) &&
> echo "gitdir: $(pwd)/realgitdir" >expected &&
> - test_cmp expected newdir/.git &&
> + case "$GIT_TEST_CMP" in
> + *--no-index*) ;; # git diff --no-index does not resolve symlinks
> + *) test_cmp expected newdir/.git;;
> + esac &&
> test_cmp expected newdir/here &&
> test_path_is_dir realgitdir/refs
> 'There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Schindelin wrote (reply to this): Hi Junio,
On Sat, 29 Nov 2025, Junio C Hamano wrote:
> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> >
> > The test case 're-init to move gitdir symlink' wants to compare the
> > contents of `newdir/.git`, which is a symbolic link pointing to a file.
> > However, `git diff --no-index`, which is used by `test_cmp` on Windows,
> > does not resolve symlinks; It shows the symlink _target_ instead (with a
> > file mode of 120000). That is totally unexpected by the test case, which
> > as a consequence fails, meaning that it's a bug in the test case itself.
>
> It is dubious if it is a bug in this particular test case, or
> test_cmp implementation that uses "git diff --no-index", though.
>
> Either way, when test_cmp here does not do "diff", the test would
> fail, so you are correct to notice that this piece of code needs to
> be patched in some way. I do not think not comparing is the right
> solution, though. Would there be a better option than completely
> punting on the comparison? Something silly like:
>
> > + case "$GIT_TEST_CMP" in
> > + # git diff --no-index does not resolve symlinks
> > + *--no-index*) cmp expected newdir/.git ;;
> > + *) test_cmp expected newdir/.git ;;
> > + esac &&
>
> perhaps?
Sure. It's not like this adds much confidence, though, as the tested-for
functionality isn't specific to Windows, so I'd expect this to fail on
Linux, too, if it was broken, and running that comparison on Windows does
not add much.
Since you spent time on this, I will change it, though.
Ciao,
Johannes
>
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> > t/t0001-init.sh | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> > index 618da080dc..2f38e09b58 100755
> > --- a/t/t0001-init.sh
> > +++ b/t/t0001-init.sh
> > @@ -425,7 +425,10 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
> > git init --separate-git-dir ../realgitdir
> > ) &&
> > echo "gitdir: $(pwd)/realgitdir" >expected &&
> > - test_cmp expected newdir/.git &&
> > + case "$GIT_TEST_CMP" in
> > + *--no-index*) ;; # git diff --no-index does not resolve symlinks
> > + *) test_cmp expected newdir/.git;;
> > + esac &&
> > test_cmp expected newdir/here &&
> > test_path_is_dir realgitdir/refs
> > '
> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> > + case "$GIT_TEST_CMP" in
>> > + # git diff --no-index does not resolve symlinks
>> > + *--no-index*) cmp expected newdir/.git ;;
>> > + *) test_cmp expected newdir/.git ;;
>> > + esac &&
>>
>> perhaps?
>
> Sure. It's not like this adds much confidence, though, as the tested-for
> functionality isn't specific to Windows, so I'd expect this to fail on
> Linux, too, if it was broken, and running that comparison on Windows does
> not add much.
It sounds like you are saying running tests on Windows on most of
the platform neutral Git code is waste of resources, and looking at
the number of shareded tests used in CI, it might not be a bad idea
if we can cleanly separate the Git functionality into two categories
(i.e., those that must behave identically on all platforms and
others) and shuffle our tests around to let platforms that runs our
tests slower only the "other" tests, while the faster platform to
run all of them. But I am not sure if that approach is a practical.
> Since you spent time on this, I will change it, though.
The time I spent does not matter as much as the time other folks
will spend scratching their heads reading the code left by this
patch. I will be mostly offline this week, so please take your
time.
Thanks.
|
||
| ) && | ||
| echo "gitdir: $(pwd)/realgitdir" >expected && | ||
| test_cmp expected newdir/.git && | ||
| case "$GIT_TEST_CMP" in | ||
| # `git diff --no-index` does not resolve symlinks | ||
| *--no-index*) cmp expected newdir/.git;; | ||
| *) test_cmp expected newdir/.git;; | ||
| esac && | ||
| test_cmp expected newdir/here && | ||
| test_path_is_dir realgitdir/refs | ||
| ' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,7 +123,8 @@ test_expect_success SYMLINKS 'use user socket if user directory is a symlink to | |
| rmdir \"\$HOME/dir/\" && | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> Just like 0fdcfa2f9f5 (t0301: fixes for windows compatibility,
> 2021-09-14) explained, we should not call `mkdir -m<mode>` in the test
> suite because that would fail on Windows (because Windows has a much
> more powerful permission system that cannot be mapped into the simpler
> user/group/other read/write/execute model).
But in this case, we are emulating "mkdir -m 700" that is expressed
in a very simpler world view of ugo=rwx with a much more powerful
permission system, isn't it? If something is more powerful, it
should be easy/possible to emulate a simpler system, I would naively
think.
In any case, a more productive than rethinking the "can we express
what mkdir -m <mode>, which is a construct in a simpler world, wants
to do in terms of a much more powerful permission system?" would be
to see if the test linter can be taught about this particular rule.
It is easy to forget that there is a platform we care about whose
testing environment that emulates POSIX does not like "mkdir -m
700", and it is a bit too much to burden developers to remember.
> There was one forgotten instance of this which was hidden by a `SYMLINK`
> prerequisite. Currently, this prevents this test case from being
> executed on Windows, but with the upcoming support for symbolic links,
> it would become a problem.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> t/t0301-credential-cache.sh | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/t/t0301-credential-cache.sh b/t/t0301-credential-cache.sh
> index dc30289f75..6f7cfd9e33 100755
> --- a/t/t0301-credential-cache.sh
> +++ b/t/t0301-credential-cache.sh
> @@ -123,7 +123,8 @@ test_expect_success SYMLINKS 'use user socket if user directory is a symlink to
> rmdir \"\$HOME/dir/\" &&
> rm \"\$HOME/.git-credential-cache\"
> " &&
> - mkdir -p -m 700 "$HOME/dir/" &&
> + mkdir -p "$HOME/dir/" &&
> + chmod 700 "$HOME/dir/" &&
That "mkdir -p -m 700" is a no-no while "mkdir -p" followed by
"chmod 700" is OK is a bit puzzling, but I assume $HOME does exist
in the testing envioronment, so this new sequence should be
equivalent in the simpler permission system. If it works fine on
Windows, that is great.
> ln -s "$HOME/dir" "$HOME/.git-credential-cache" &&
> check approve cache <<-\EOF &&
> protocol=httpsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Schindelin wrote (reply to this): Hi Junio,
On Sat, 29 Nov 2025, Junio C Hamano wrote:
> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> >
> > Just like 0fdcfa2f9f5 (t0301: fixes for windows compatibility,
> > 2021-09-14) explained, we should not call `mkdir -m<mode>` in the test
> > suite because that would fail on Windows (because Windows has a much
> > more powerful permission system that cannot be mapped into the simpler
> > user/group/other read/write/execute model).
>
> But in this case, we are emulating "mkdir -m 700" that is expressed
> in a very simpler world view of ugo=rwx with a much more powerful
> permission system, isn't it? If something is more powerful, it
> should be easy/possible to emulate a simpler system, I would naively
> think.
It is probably outside the purview of this patch series to question why
Cygwin's `mkdir -m` doesn't emulate Unix semantics let alone to fix it. So
I'll bow out of that tangent.
> In any case, a more productive than rethinking the "can we express
> what mkdir -m <mode>, which is a construct in a simpler world, wants
> to do in terms of a much more powerful permission system?" would be
> to see if the test linter can be taught about this particular rule.
Seeing that this issue had to be fixed twice within the course of over 4
years, https://xkcd.com/1205/ applies.
Ciao,
Johannes
>
> It is easy to forget that there is a platform we care about whose
> testing environment that emulates POSIX does not like "mkdir -m
> 700", and it is a bit too much to burden developers to remember.
>
> > There was one forgotten instance of this which was hidden by a `SYMLINK`
> > prerequisite. Currently, this prevents this test case from being
> > executed on Windows, but with the upcoming support for symbolic links,
> > it would become a problem.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> > t/t0301-credential-cache.sh | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/t/t0301-credential-cache.sh b/t/t0301-credential-cache.sh
> > index dc30289f75..6f7cfd9e33 100755
> > --- a/t/t0301-credential-cache.sh
> > +++ b/t/t0301-credential-cache.sh
> > @@ -123,7 +123,8 @@ test_expect_success SYMLINKS 'use user socket if user directory is a symlink to
> > rmdir \"\$HOME/dir/\" &&
> > rm \"\$HOME/.git-credential-cache\"
> > " &&
> > - mkdir -p -m 700 "$HOME/dir/" &&
> > + mkdir -p "$HOME/dir/" &&
> > + chmod 700 "$HOME/dir/" &&
>
> That "mkdir -p -m 700" is a no-no while "mkdir -p" followed by
> "chmod 700" is OK is a bit puzzling, but I assume $HOME does exist
> in the testing envioronment, so this new sequence should be
> equivalent in the simpler permission system. If it works fine on
> Windows, that is great.
>
> > ln -s "$HOME/dir" "$HOME/.git-credential-cache" &&
> > check approve cache <<-\EOF &&
> > protocol=https
> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> In any case, a more productive than rethinking the "can we express
>> what mkdir -m <mode>, which is a construct in a simpler world, wants
>> to do in terms of a much more powerful permission system?" would be
>> to see if the test linter can be taught about this particular rule.
>
> Seeing that this issue had to be fixed twice within the course of over 4
> years, https://xkcd.com/1205/ applies.
It means that we are punting and are not proactively helping future
developers who may make the same mistake, but we expect it would be
rather rare so I am OK with us making that trade-off. But then can
you dial back your condescending tone against those who are not as
familiar as glitches in the Windows port of POSIX shell environment
we use for tests?
Thanks.
>> It is easy to forget that there is a platform we care about whose
>> testing environment that emulates POSIX does not like "mkdir -m
>> 700", and it is a bit too much to burden developers to remember.There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Schindelin wrote (reply to this): Hi Junio,
On Tue, 2 Dec 2025, Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> >> In any case, a more productive than rethinking the "can we express
> >> what mkdir -m <mode>, which is a construct in a simpler world, wants
> >> to do in terms of a much more powerful permission system?" would be
> >> to see if the test linter can be taught about this particular rule.
> >
> > Seeing that this issue had to be fixed twice within the course of over 4
> > years, https://xkcd.com/1205/ applies.
>
> It means that we are punting and are not proactively helping future
> developers who may make the same mistake, but we expect it would be
> rather rare so I am OK with us making that trade-off.
Good, then we're on the same page regarding this approach.
> But then can you dial back your condescending tone against those who are
> not as familiar as glitches in the Windows port of POSIX shell
> environment we use for tests?
Please don't read more into my words than merely a large frustration with
the state of Git's test suite. It might be mostly conforming to the 80
character per line convention, yet I yearn instead for the same speed,
readability, portability and debuggability that I've encountered in other
projects' test suites.
Ciao,
Johannes |
||
| rm \"\$HOME/.git-credential-cache\" | ||
| " && | ||
| mkdir -p -m 700 "$HOME/dir/" && | ||
| mkdir -p "$HOME/dir/" && | ||
| chmod 700 "$HOME/dir/" && | ||
| ln -s "$HOME/dir" "$HOME/.git-credential-cache" && | ||
| check approve cache <<-\EOF && | ||
| protocol=https | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -467,7 +467,7 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' ' | |
| esac | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Patrick Steinhardt wrote (reply to this): On Sat, Nov 29, 2025 at 06:28:22PM +0000, Johannes Schindelin via GitGitGadget wrote:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> The 'symref transaction supports symlinks' test case is guarded by the
> `SYMLINK` prerequisite because `core.prefersymlinkrefs = true` requires
> symbolic links to be supported.
>
> However, the `preferSymlinkRefs` feature is not supported on Windows,
> therefore this test case needs the `MINGW` prerequisite, too.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> t/t0600-reffiles-backend.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t0600-reffiles-backend.sh b/t/t0600-reffiles-backend.sh
> index b11126ed47..74bfa2e9ba 100755
> --- a/t/t0600-reffiles-backend.sh
> +++ b/t/t0600-reffiles-backend.sh
> @@ -467,7 +467,7 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
> esac
> '
>
> -test_expect_success SYMLINKS 'symref transaction supports symlinks' '
> +test_expect_success SYMLINKS,!MINGW 'symref transaction supports symlinks' '
> test_when_finished "git symbolic-ref -d TEST_SYMREF_HEAD" &&
> git update-ref refs/heads/new @ &&
> test_config core.prefersymlinkrefs true &&
Makes sense. There's a couple more cases where we set this config key:
- In a subsequent test in t0600, but there we explicitly set it to
"false". So this would naturally be supported by Windows.
- In t7201 we set the value to "yes", but we never verify that the
written reference is a symbolic link in the first place. I guess
that we could rather remove setting the configuration value here, as
we are about to deprecate support for symrefs via symbolic links in
the first place. But that's certainly outside of the scope of this
series.
- In t9903 we do the same, but likewise, we don't check whether the
written file is a symbolic link.
So yes, this seems to be the only instance where we actually need to
adapt tests.
Thanks!
PatrickThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Schindelin wrote (reply to this): Hi Patrick,
On Mon, 1 Dec 2025, Patrick Steinhardt wrote:
> On Sat, Nov 29, 2025 at 06:28:22PM +0000, Johannes Schindelin via GitGitGadget wrote:
> > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> >
> > The 'symref transaction supports symlinks' test case is guarded by the
> > `SYMLINK` prerequisite because `core.prefersymlinkrefs = true` requires
> > symbolic links to be supported.
> >
> > However, the `preferSymlinkRefs` feature is not supported on Windows,
> > therefore this test case needs the `MINGW` prerequisite, too.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ---
> > t/t0600-reffiles-backend.sh | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/t/t0600-reffiles-backend.sh b/t/t0600-reffiles-backend.sh
> > index b11126ed47..74bfa2e9ba 100755
> > --- a/t/t0600-reffiles-backend.sh
> > +++ b/t/t0600-reffiles-backend.sh
> > @@ -467,7 +467,7 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
> > esac
> > '
> >
> > -test_expect_success SYMLINKS 'symref transaction supports symlinks' '
> > +test_expect_success SYMLINKS,!MINGW 'symref transaction supports symlinks' '
> > test_when_finished "git symbolic-ref -d TEST_SYMREF_HEAD" &&
> > git update-ref refs/heads/new @ &&
> > test_config core.prefersymlinkrefs true &&
>
> Makes sense. There's a couple more cases where we set this config key:
>
> - In a subsequent test in t0600, but there we explicitly set it to
> "false". So this would naturally be supported by Windows.
>
> - In t7201 we set the value to "yes", but we never verify that the
> written reference is a symbolic link in the first place. I guess
> that we could rather remove setting the configuration value here, as
> we are about to deprecate support for symrefs via symbolic links in
> the first place. But that's certainly outside of the scope of this
> series.
>
> - In t9903 we do the same, but likewise, we don't check whether the
> written file is a symbolic link.
>
> So yes, this seems to be the only instance where we actually need to
> adapt tests.
Thank you for doing my homework. I meant to jot it down in my TODO list as
something that I needed to check before sending the series, but I forgot
to jot it down and therefore forgot.
Thanks again!
Johannes |
||
| ' | ||
|
|
||
| test_expect_success SYMLINKS 'symref transaction supports symlinks' ' | ||
| test_expect_success SYMLINKS,!MINGW 'symref transaction supports symlinks' ' | ||
| test_when_finished "git symbolic-ref -d TEST_SYMREF_HEAD" && | ||
| git update-ref refs/heads/new @ && | ||
| test_config core.prefersymlinkrefs true && | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1048,18 +1048,28 @@ test_expect_success 'git cat-file --batch-check --follow-symlinks works for out- | |
| echo .. >>expect && | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Patrick Steinhardt wrote (reply to this): On Sat, Nov 29, 2025 at 06:28:23PM +0000, Johannes Schindelin via GitGitGadget wrote:
> diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
> index 1f61b666a7..0eee3bb878 100755
> --- a/t/t1006-cat-file.sh
> +++ b/t/t1006-cat-file.sh
> @@ -1048,18 +1048,28 @@ test_expect_success 'git cat-file --batch-check --follow-symlinks works for out-
> echo .. >>expect &&
> echo HEAD:dir/subdir/out-of-repo-link-dir | git cat-file --batch-check --follow-symlinks >actual &&
> test_cmp expect actual &&
> - echo symlink 3 >expect &&
> - echo ../ >>expect &&
> + if test_have_prereq MINGW,SYMLINKS
> + then
> + test_write_lines "symlink 2" ..
> + else
> + test_write_lines "symlink 3" ../
> + fi >expect &&
> echo HEAD:dir/subdir/out-of-repo-link-dir-trailing | git cat-file --batch-check --follow-symlinks >actual &&
> test_cmp expect actual
> '
Okay.
> test_expect_success 'git cat-file --batch-check --follow-symlinks works for symlinks with internal ..' '
> - echo HEAD: | git cat-file --batch-check >expect &&
> - echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual &&
> - test_cmp expect actual &&
> - echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual &&
> - test_cmp expect actual &&
> + if test_have_prereq !MINGW
> + then
> + # The `up-down` and `up-down-trailing` symlinks are normalized
> + # in MSYS in `winsymlinks` mode and are therefore in a
> + # different shape than Git expects them.
> + echo HEAD: | git cat-file --batch-check >expect &&
> + echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual &&
> + test_cmp expect actual &&
> + echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual &&
> + test_cmp expect actual
> + fi &&
> echo HEAD:up-down-file | git cat-file --batch-check --follow-symlinks >actual &&
> test_cmp found actual &&
> echo symlink 7 >expect &&
I'm not quite sure I follow, so my questions may be dumb. Does this mean
that git-cat-file(1) fails to follow the symlink in this case, and
consequently we cannot execute it at all? If so, is this a bug that
we'll eventually have to fix?
If this is something we can fix it could be sensible to have an `else`
branch that documents the failure case. In that case, we would then
notice that the test fails once we fix the underlying issue.
PatrickThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Schindelin wrote (reply to this): Hi Patrick,
On Mon, 1 Dec 2025, Patrick Steinhardt wrote:
> On Sat, Nov 29, 2025 at 06:28:23PM +0000, Johannes Schindelin via GitGitGadget wrote:
>
> > test_expect_success 'git cat-file --batch-check --follow-symlinks works for symlinks with internal ..' '
> > - echo HEAD: | git cat-file --batch-check >expect &&
> > - echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual &&
> > - test_cmp expect actual &&
> > - echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual &&
> > - test_cmp expect actual &&
> > + if test_have_prereq !MINGW
> > + then
> > + # The `up-down` and `up-down-trailing` symlinks are normalized
> > + # in MSYS in `winsymlinks` mode and are therefore in a
> > + # different shape than Git expects them.
> > + echo HEAD: | git cat-file --batch-check >expect &&
> > + echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual &&
> > + test_cmp expect actual &&
> > + echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual &&
> > + test_cmp expect actual
> > + fi &&
> > echo HEAD:up-down-file | git cat-file --batch-check --follow-symlinks >actual &&
> > test_cmp found actual &&
> > echo symlink 7 >expect &&
>
> I'm not quite sure I follow, so my questions may be dumb. Does this mean
> that git-cat-file(1) fails to follow the symlink in this case, and
> consequently we cannot execute it at all? If so, is this a bug that
> we'll eventually have to fix?
No, it means that the symbolic links are not even created in the way Git's
test suite thinks they are (or should be) created. The way those symbolic
link targets exist on disk (i.e. the way Cygwin's
`winsymlinks:nativestrict` mode constructs them), the expectations of this
test cannot be met, no matter what `cat-file` does.
Ciao,
JohannesThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Patrick Steinhardt wrote (reply to this): On Mon, Dec 01, 2025 at 02:29:45PM +0100, Johannes Schindelin wrote:
> Hi Patrick,
>
> On Mon, 1 Dec 2025, Patrick Steinhardt wrote:
>
> > On Sat, Nov 29, 2025 at 06:28:23PM +0000, Johannes Schindelin via GitGitGadget wrote:
> >
> > > test_expect_success 'git cat-file --batch-check --follow-symlinks works for symlinks with internal ..' '
> > > - echo HEAD: | git cat-file --batch-check >expect &&
> > > - echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual &&
> > > - test_cmp expect actual &&
> > > - echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual &&
> > > - test_cmp expect actual &&
> > > + if test_have_prereq !MINGW
> > > + then
> > > + # The `up-down` and `up-down-trailing` symlinks are normalized
> > > + # in MSYS in `winsymlinks` mode and are therefore in a
> > > + # different shape than Git expects them.
> > > + echo HEAD: | git cat-file --batch-check >expect &&
> > > + echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual &&
> > > + test_cmp expect actual &&
> > > + echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual &&
> > > + test_cmp expect actual
> > > + fi &&
> > > echo HEAD:up-down-file | git cat-file --batch-check --follow-symlinks >actual &&
> > > test_cmp found actual &&
> > > echo symlink 7 >expect &&
> >
> > I'm not quite sure I follow, so my questions may be dumb. Does this mean
> > that git-cat-file(1) fails to follow the symlink in this case, and
> > consequently we cannot execute it at all? If so, is this a bug that
> > we'll eventually have to fix?
>
> No, it means that the symbolic links are not even created in the way Git's
> test suite thinks they are (or should be) created. The way those symbolic
> link targets exist on disk (i.e. the way Cygwin's
> `winsymlinks:nativestrict` mode constructs them), the expectations of this
> test cannot be met, no matter what `cat-file` does.
Ah, makes sense. Thanks for clarifying!
Patrick |
||
| echo HEAD:dir/subdir/out-of-repo-link-dir | git cat-file --batch-check --follow-symlinks >actual && | ||
| test_cmp expect actual && | ||
| echo symlink 3 >expect && | ||
| echo ../ >>expect && | ||
| if test_have_prereq MINGW,SYMLINKS | ||
| then | ||
| test_write_lines "symlink 2" .. | ||
| else | ||
| test_write_lines "symlink 3" ../ | ||
| fi >expect && | ||
| echo HEAD:dir/subdir/out-of-repo-link-dir-trailing | git cat-file --batch-check --follow-symlinks >actual && | ||
| test_cmp expect actual | ||
| ' | ||
|
|
||
| test_expect_success 'git cat-file --batch-check --follow-symlinks works for symlinks with internal ..' ' | ||
| echo HEAD: | git cat-file --batch-check >expect && | ||
| echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual && | ||
| test_cmp expect actual && | ||
| echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual && | ||
| test_cmp expect actual && | ||
| if test_have_prereq !MINGW | ||
| then | ||
| # The `up-down` and `up-down-trailing` symlinks are normalized | ||
| # in MSYS in `winsymlinks` mode and are therefore in a | ||
| # different shape than Git expects them. | ||
| echo HEAD: | git cat-file --batch-check >expect && | ||
| echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual && | ||
| test_cmp expect actual && | ||
| echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual && | ||
| test_cmp expect actual | ||
| fi && | ||
| echo HEAD:up-down-file | git cat-file --batch-check --follow-symlinks >actual && | ||
| test_cmp found actual && | ||
| echo symlink 7 >expect && | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -752,11 +752,11 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' ' | |
| c | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Junio C Hamano wrote (reply to this): "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> Git's test suite's relies on Unix shell scripting, which is
> understandable, of course, given Git's firm roots (and indeed, ongoing
> focus) on Linux.
>
> This fact, combined with Unix shell scripting's natural
> habitat -- which is, naturally... *drumroll*... Unix --
> often has unintended side effects, where developers expect the test
> suite to run in a Unix environment, which is an incorrect assumption.
Surely, those who are primarily on Linux, or those whose background
is from other kinds of UNIX, cannot be expected to be intimately
familiar with how the POSIX shell script environment ported to
Windows platform behaves, and it is understandable if they expect,
as a port, it would behave more or less the same way as they are
accustomed to on UNIX. Even though POSIX shell script environment
used to run our end-to-end tests are ported to Windows, however, the
scripts still need to be aware of certain things that have to be
done differently in Windows environment from how they are done in
UNIX environment. Here what you fixed, the absolute pathname may
begin with <drive> <colon> instead of <slash>, may be one of them.
And these differences are not necessarily well known and/or
advertised to many of the developers who have written our tests on
Linux or macOS over time. I wonder if we can do something about
that, instead of reacting to breakage retroactively while
complaining with disgust about the platform differences, which is
what we often have to see on this list.
> Let's instead rely on the much more reliable fact that
> `ls` will output the path in a line that ends in a colon, and simply
> filter out those lines by matching said colon instead.
That is clever and clean, a very well crafted solution.
Will queue. The entire series looked quite sensibly reasoned.
Thanks.There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Eric Sunshine wrote (reply to this): On Sat, Nov 29, 2025 at 1:29 PM Johannes Schindelin via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> Git's test suite's relies on Unix shell scripting, which is
> understandable, of course, given Git's firm roots (and indeed, ongoing
> focus) on Linux.
>
> This fact, combined with Unix shell scripting's natural
> habitat -- which is, naturally... *drumroll*... Unix --
> often has unintended side effects, where developers expect the test
> suite to run in a Unix environment, which is an incorrect assumption.
>
> One instance of this problem can be observed in the 'difftool --dir-diff
> handles modified symlinks' test case in `t7800-difftool.sh`, which
> assumes that that all absolute paths start with a forward slash. That
s/that that/that/
> assumption is incorrect in general, e.g. on Windows, where absolute
> paths have many shapes and forms, none of which starts with a forward
> slash.
>
> The only saving grace is that this test case is currently not run on
> Windows because of the `SYMLINK` prerequisite. However, I am currently
> working towards upstreaming symbolic link support from Git for Windows
> to upstream Git, which will put a crack into that saving grace.
>
> Let's change that test case so that it does not rely on absolute paths
> (which are passed to the "external command" `ls` as parameters and are
> therefore part of its output, and which the test case wants to filter
> out before verifying that the output is as expected) starting with a
> forward slash. Let's instead rely on the much more reliable fact that
> `ls` will output the path in a line that ends in a colon, and simply
> filter out those lines by matching said colon instead.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Schindelin wrote (reply to this): Hi Eric,
On Sun, 30 Nov 2025, Eric Sunshine wrote:
> On Sat, Nov 29, 2025 at 1:29 PM Johannes Schindelin via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> > Git's test suite's relies on Unix shell scripting, which is
> > understandable, of course, given Git's firm roots (and indeed, ongoing
> > focus) on Linux.
> >
> > This fact, combined with Unix shell scripting's natural
> > habitat -- which is, naturally... *drumroll*... Unix --
> > often has unintended side effects, where developers expect the test
> > suite to run in a Unix environment, which is an incorrect assumption.
> >
> > One instance of this problem can be observed in the 'difftool --dir-diff
> > handles modified symlinks' test case in `t7800-difftool.sh`, which
> > assumes that that all absolute paths start with a forward slash. That
>
> s/that that/that/
Thanks,
Johannes
>
> > assumption is incorrect in general, e.g. on Windows, where absolute
> > paths have many shapes and forms, none of which starts with a forward
> > slash.
> >
> > The only saving grace is that this test case is currently not run on
> > Windows because of the `SYMLINK` prerequisite. However, I am currently
> > working towards upstreaming symbolic link support from Git for Windows
> > to upstream Git, which will put a crack into that saving grace.
> >
> > Let's change that test case so that it does not rely on absolute paths
> > (which are passed to the "external command" `ls` as parameters and are
> > therefore part of its output, and which the test case wants to filter
> > out before verifying that the output is as expected) starting with a
> > forward slash. Let's instead rely on the much more reliable fact that
> > `ls` will output the path in a line that ends in a colon, and simply
> > filter out those lines by matching said colon instead.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> |
||
| EOF | ||
| git difftool --symlinks --dir-diff --extcmd ls >output && | ||
| grep -v ^/ output >actual && | ||
| grep -v ":\$" output >actual && | ||
| test_cmp expect actual && | ||
|
|
||
| git difftool --no-symlinks --dir-diff --extcmd ls >output && | ||
| grep -v ^/ output >actual && | ||
| grep -v ":\$" output >actual && | ||
| test_cmp expect actual && | ||
|
|
||
| # The left side contains symlink "c" that points to "b" | ||
|
|
@@ -786,11 +786,11 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' ' | |
|
|
||
| EOF | ||
| git difftool --symlinks --dir-diff --extcmd ls >output && | ||
| grep -v ^/ output >actual && | ||
| grep -v ":\$" output >actual && | ||
| test_cmp expect actual && | ||
|
|
||
| git difftool --no-symlinks --dir-diff --extcmd ls >output && | ||
| grep -v ^/ output >actual && | ||
| grep -v ":\$" output >actual && | ||
| test_cmp expect actual | ||
| ' | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Junio C Hamano wrote (reply to this):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Johannes Schindelin wrote (reply to this):