# [PATCH] some test fixes for msysGit

11 messages from 2011-02-03 to 2011-02-04. Participants: Pat Thoyts, Johannes Schindelin, Johannes Sixt.
Thread: https://gitlist.dev/t/26400

## Pat Thoyts, 2011-02-03 15:31

Subject: [PATCH] some test fixes for msysGit
Message-ID: <1296747105-1663-1-git-send-email-patthoyts@users.sourceforge.net>
URL: https://gitlist.dev/e/1296747105-1663-1-git-send-email-patthoyts%40users.sourceforge.net

```
The following patches resolve some issues for msysGit running the v1.7.4 tests

 t/t3509-cherry-pick-merge-df.sh |    6 ++++--
 t/t4120-apply-popt.sh           |    9 +++++++--
 t/t5526-fetch-submodules.sh     |   32 ++++++++++++++++++--------------
 t/t7407-submodule-foreach.sh    |    4 ++++
 4 files changed, 33 insertions(+), 18 deletions(-)

```

## Pat Thoyts, 2011-02-03 15:31

Subject: [PATCH 1/4] t3509: use unconstrained initial test to setup repository.
Message-ID: <1296747105-1663-2-git-send-email-patthoyts@users.sourceforge.net>
URL: https://gitlist.dev/e/1296747105-1663-2-git-send-email-patthoyts%40users.sourceforge.net
In-Reply-To: <1296747105-1663-1-git-send-email-patthoyts@users.sourceforge.net>

```
The first test did not run on msysGit due to the SYMLINKS constraint and
so subsequent tests failed because the test repository was not initialized.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
 t/t3509-cherry-pick-merge-df.sh |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/t3509-cherry-pick-merge-df.sh b/t/t3509-cherry-pick-merge-df.sh
index 948ca1b..df921d1 100755
--- a/t/t3509-cherry-pick-merge-df.sh
+++ b/t/t3509-cherry-pick-merge-df.sh
@@ -3,12 +3,14 @@
 test_description='Test cherry-pick with directory/file conflicts'
 . ./test-lib.sh
 
-test_expect_success SYMLINKS 'Setup rename across paths each below D/F conflicts' '
+test_expect_success 'Initialize repository' '
 	mkdir a &&
 	>a/f &&
 	git add a &&
-	git commit -m a &&
+	git commit -m a
+'
 
+test_expect_success SYMLINKS 'Setup rename across paths each below D/F conflicts' '
 	mkdir b &&
 	ln -s ../a b/a &&
 	git add b &&
-- 
1.7.4.msysgit.0

```

## Pat Thoyts, 2011-02-03 15:31

Subject: [PATCH 2/4] t4120-apply-popt: help systems with core.filemode=false
Message-ID: <1296747105-1663-3-git-send-email-patthoyts@users.sourceforge.net>
URL: https://gitlist.dev/e/1296747105-1663-3-git-send-email-patthoyts%40users.sourceforge.net
In-Reply-To: <1296747105-1663-1-git-send-email-patthoyts@users.sourceforge.net>

```
From: Johannes Sixt <j6t@kdbg.org>

A test case verifies that filemode-only patches work as expected. Help
systems where "test -x" does not work by applying the test patch also to
the index, where the effects can be verified even on such systems.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
 t/t4120-apply-popt.sh |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh
index 579c9e6..a33d510 100755
--- a/t/t4120-apply-popt.sh
+++ b/t/t4120-apply-popt.sh
@@ -6,6 +6,7 @@
 test_description='git apply -p handling.'
 
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
 
 test_expect_success setup '
 	mkdir sub &&
@@ -62,8 +63,12 @@ test_expect_success 'apply (-p2) diff, mode change only' '
 	old mode 100644
 	new mode 100755
 	EOF
-	chmod 644 file1 &&
-	git apply -p2 patch.chmod &&
+	test_chmod -x file1 &&
+	git apply --index -p2 patch.chmod &&
+	case $(git ls-files -s file1) in 100755*) : good;; *) false;; esac
+'
+
+test_expect_success FILEMODE 'file mode was changed' '
 	test -x file1
 '
 
-- 
1.7.4.msysgit.0

```

## Pat Thoyts, 2011-02-03 15:31

Subject: [PATCH 3/4] t7407: fix line endings for mingw build
Message-ID: <1296747105-1663-4-git-send-email-patthoyts@users.sourceforge.net>
URL: https://gitlist.dev/e/1296747105-1663-4-git-send-email-patthoyts%40users.sourceforge.net
In-Reply-To: <1296747105-1663-1-git-send-email-patthoyts@users.sourceforge.net>

```
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
 t/t7407-submodule-foreach.sh |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
index 1d67ef5..4c84764 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -254,6 +254,10 @@ test_expect_success 'ensure "status --cached --recursive" preserves the --cached
 		) &&
 		git submodule status --cached --recursive -- nested1 > ../actual
 	) &&
+	if test_have_prereq MINGW
+	then
+		dos2unix actual
+	fi &&
 	test_cmp expect actual
 '
 
-- 
1.7.4.msysgit.0

```

## Pat Thoyts, 2011-02-03 15:31

Subject: [PATCH 4/4] t5526: avoid dependency on submodule order
Message-ID: <1296747105-1663-5-git-send-email-patthoyts@users.sourceforge.net>
URL: https://gitlist.dev/e/1296747105-1663-5-git-send-email-patthoyts%40users.sourceforge.net
In-Reply-To: <1296747105-1663-1-git-send-email-patthoyts@users.sourceforge.net>

```
When running tests on msysGit the actual results appear in the reverse
order. Added a test_cmp_unordered to test that each expected line is
present in the output without depending upon the order of lines.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
 t/t5526-fetch-submodules.sh |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index 884a5e5..d218845 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -32,6 +32,10 @@ add_upstream_commit() {
 	)
 }
 
+test_cmp_unordered() {
+	grep --line-regexp -f "$@" >&3
+}
+
 test_expect_success setup '
 	mkdir deepsubmodule &&
 	(
@@ -67,8 +71,8 @@ test_expect_success "fetch --recurse-submodules recurses into submodules" '
 		cd downstream &&
 		git fetch --recurse-submodules >../actual.out 2>../actual.err
 	) &&
-	test_cmp expect.out actual.out &&
-	test_cmp expect.err actual.err
+	test_cmp_unordered expect.out actual.out &&
+	test_cmp_unordered expect.err actual.err
 '
 
 test_expect_success "fetch alone only fetches superproject" '
@@ -96,8 +100,8 @@ test_expect_success "using fetchRecurseSubmodules=true in .gitmodules recurses i
 		git config -f .gitmodules submodule.submodule.fetchRecurseSubmodules true &&
 		git fetch >../actual.out 2>../actual.err
 	) &&
-	test_cmp expect.out actual.out &&
-	test_cmp expect.err actual.err
+	test_cmp_unordered expect.out actual.out &&
+	test_cmp_unordered expect.err actual.err
 '
 
 test_expect_success "--no-recurse-submodules overrides .gitmodules config" '
@@ -127,8 +131,8 @@ test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setti
 		git config -f --unset .gitmodules submodule.submodule.fetchRecurseSubmodules true &&
 		git config --unset submodule.submodule.fetchRecurseSubmodules
 	) &&
-	test_cmp expect.out actual.out &&
-	test_cmp expect.err actual.err
+	test_cmp_unordered expect.out actual.out &&
+	test_cmp_unordered expect.err actual.err
 '
 
 test_expect_success "--quiet propagates to submodules" '
@@ -146,14 +150,14 @@ test_expect_success "--dry-run propagates to submodules" '
 		cd downstream &&
 		git fetch --recurse-submodules --dry-run >../actual.out 2>../actual.err
 	) &&
-	test_cmp expect.out actual.out &&
-	test_cmp expect.err actual.err &&
+	test_cmp_unordered expect.out actual.out &&
+	test_cmp_unordered expect.err actual.err &&
 	(
 		cd downstream &&
 		git fetch --recurse-submodules >../actual.out 2>../actual.err
 	) &&
-	test_cmp expect.out actual.out &&
-	test_cmp expect.err actual.err
+	test_cmp_unordered expect.out actual.out &&
+	test_cmp_unordered expect.err actual.err
 '
 
 test_expect_success "recurseSubmodules=true propagates into submodules" '
@@ -163,8 +167,8 @@ test_expect_success "recurseSubmodules=true propagates into submodules" '
 		git config fetch.recurseSubmodules true
 		git fetch >../actual.out 2>../actual.err
 	) &&
-	test_cmp expect.out actual.out &&
-	test_cmp expect.err actual.err
+	test_cmp_unordered expect.out actual.out &&
+	test_cmp_unordered expect.err actual.err
 '
 
 test_expect_success "--recurse-submodules overrides config in submodule" '
@@ -177,8 +181,8 @@ test_expect_success "--recurse-submodules overrides config in submodule" '
 		) &&
 		git fetch --recurse-submodules >../actual.out 2>../actual.err
 	) &&
-	test_cmp expect.out actual.out &&
-	test_cmp expect.err actual.err
+	test_cmp_unordered expect.out actual.out &&
+	test_cmp_unordered expect.err actual.err
 '
 
 test_expect_success "--no-recurse-submodules overrides config setting" '
-- 
1.7.4.msysgit.0

```

## Johannes Schindelin, 2011-02-03 16:29

Subject: Re: [msysGit] [PATCH] some test fixes for msysGit
Message-ID: <alpine.DEB.1.00.1102031028150.1541@bonsai2>
URL: https://gitlist.dev/e/alpine.DEB.1.00.1102031028150.1541%40bonsai2
In-Reply-To: <1296747105-1663-1-git-send-email-patthoyts@users.sourceforge.net>

```
Hi,

On Thu, 3 Feb 2011, Pat Thoyts wrote:

> The following patches resolve some issues for msysGit running the v1.7.4 
> tests
> 
>  t/t3509-cherry-pick-merge-df.sh |    6 ++++--
>  t/t4120-apply-popt.sh           |    9 +++++++--
>  t/t5526-fetch-submodules.sh     |   32 ++++++++++++++++++--------------
>  t/t7407-submodule-foreach.sh    |    4 ++++
>  4 files changed, 33 insertions(+), 18 deletions(-)

I looked at the first three and think they are obviously fine.

As I mentioned, I would like to have a fix for the order in git-submodule. 
If you do not have the time, I will try to push aside some of the work I 
have to do here and investigate myself.

Ciao,
Dscho

```

## Johannes Sixt, 2011-02-03 20:08

Subject: Re: [msysGit] [PATCH 4/4] t5526: avoid dependency on submodule order
Message-ID: <201102032108.54811.j6t@kdbg.org>
URL: https://gitlist.dev/e/201102032108.54811.j6t%40kdbg.org
In-Reply-To: <1296747105-1663-5-git-send-email-patthoyts@users.sourceforge.net>

```
On Donnerstag, 3. Februar 2011, Pat Thoyts wrote:
> +test_cmp_unordered() {
> +	grep --line-regexp -f "$@" >&3
> +}

I don't think that this is sufficiently portable.

Furthermore, just like Dscho, I'd rather prefer to know why the output is not 
ordered as expected.

I'm fine with the other patches as well.

A side note regarding SYMLINKS: It's actually possible to remove 70 of the 130 
SYMLINKS checks from the test suite:

http://repo.or.cz/w/git/mingw/j6t.git/shortlog/refs/heads/war-on-symlinks

-- Hannes

```

## Johannes Schindelin, 2011-02-03 20:26

Subject: Re: [msysGit] [PATCH 4/4] t5526: avoid dependency on submodule order
Message-ID: <alpine.DEB.1.00.1102031426110.1541@bonsai2>
URL: https://gitlist.dev/e/alpine.DEB.1.00.1102031426110.1541%40bonsai2
In-Reply-To: <201102032108.54811.j6t@kdbg.org>

```
Hi,

On Thu, 3 Feb 2011, Johannes Sixt wrote:

> On Donnerstag, 3. Februar 2011, Pat Thoyts wrote:
> > +test_cmp_unordered() {
> > +	grep --line-regexp -f "$@" >&3
> > +}
> 
> I don't think that this is sufficiently portable.
> 
> Furthermore, just like Dscho, I'd rather prefer to know why the output 
> is not ordered as expected.

Have you seen my response where I proved that it is a fflush() issue, most 
likely with mingw_spawn()?

Ciao,
Dscho

```

## Johannes Sixt, 2011-02-03 20:56

Subject: Re: [msysGit] [PATCH 4/4] t5526: avoid dependency on submodule order
Message-ID: <201102032156.15646.j6t@kdbg.org>
URL: https://gitlist.dev/e/201102032156.15646.j6t%40kdbg.org
In-Reply-To: <alpine.DEB.1.00.1102031426110.1541@bonsai2>

```
On Donnerstag, 3. Februar 2011, Johannes Schindelin wrote:
> On Thu, 3 Feb 2011, Johannes Sixt wrote:
> > Furthermore, just like Dscho, I'd rather prefer to know why the output
> > is not ordered as expected.
>
> Have you seen my response where I proved that it is a fflush() issue, most
> likely with mingw_spawn()?

Obviously, I haven't. Good catch!

-- Hannes

```

## Johannes Sixt, 2011-02-04 08:41

Subject: [PATCH maint] start_command: flush buffers in the WIN32 code path as well
Message-ID: <4D4BBBD6.7010100@viscovery.net>
URL: https://gitlist.dev/e/4D4BBBD6.7010100%40viscovery.net
In-Reply-To: <alpine.DEB.1.00.1102031426110.1541@bonsai2>

```
From: Johannes Sixt <j6t@kdbg.org>

The POSIX code path did The Right Thing already, but we have to do the same
on Windows.

This bug caused failures in t5526-fetch-submodules, where the output of
'git fetch --recurse-submodules' was in the wrong order.

Debugged-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
Am 2/3/2011 21:26, schrieb Johannes Schindelin:
> Have you seen my response where I proved that it is a fflush() issue, most 
> likely with mingw_spawn()?

I think this is the correct fix.

 run-command.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/run-command.c b/run-command.c
index 2a1041e..f91e446 100644
--- a/run-command.c
+++ b/run-command.c
@@ -194,6 +194,7 @@ fail_pipe:
 	}
 
 	trace_argv_printf(cmd->argv, "trace: run_command:");
+	fflush(NULL);
 
 #ifndef WIN32
 {
@@ -201,7 +202,6 @@ fail_pipe:
 	if (pipe(notify_pipe))
 		notify_pipe[0] = notify_pipe[1] = -1;
 
-	fflush(NULL);
 	cmd->pid = fork();
 	if (!cmd->pid) {
 		/*
-- 
1.7.4.1253.g00c7

```

## Pat Thoyts, 2011-02-04 11:23

Subject: Re: [PATCH maint] start_command: flush buffers in the WIN32 code path as well
Message-ID: <87sjw4jb5q.fsf@fox.patthoyts.tk>
URL: https://gitlist.dev/e/87sjw4jb5q.fsf%40fox.patthoyts.tk
In-Reply-To: <4D4BBBD6.7010100@viscovery.net>

```
Johannes Sixt <j.sixt@viscovery.net> writes:

>From: Johannes Sixt <j6t@kdbg.org>
>
>The POSIX code path did The Right Thing already, but we have to do the same
>on Windows.
>
>This bug caused failures in t5526-fetch-submodules, where the output of
>'git fetch --recurse-submodules' was in the wrong order.
>
>Debugged-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>Signed-off-by: Johannes Sixt <j6t@kdbg.org>
>---
>Am 2/3/2011 21:26, schrieb Johannes Schindelin:
>> Have you seen my response where I proved that it is a fflush() issue, most 
>> likely with mingw_spawn()?
>
>I think this is the correct fix.
>
> run-command.c |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
>diff --git a/run-command.c b/run-command.c
>index 2a1041e..f91e446 100644
>--- a/run-command.c
>+++ b/run-command.c
>@@ -194,6 +194,7 @@ fail_pipe:
> 	}
> 
> 	trace_argv_printf(cmd->argv, "trace: run_command:");
>+	fflush(NULL);
> 
> #ifndef WIN32
> {
>@@ -201,7 +202,6 @@ fail_pipe:
> 	if (pipe(notify_pipe))
> 		notify_pipe[0] = notify_pipe[1] = -1;
> 
>-	fflush(NULL);
> 	cmd->pid = fork();
> 	if (!cmd->pid) {
> 		/*

This fixes the issue for me on msysGit. Thanks.

-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

```
