Re: [PATCH] t0021, t5615: use $PWD instead of $(pwd) in PATH-like shell variables

2 messages, 2 authors, 2016-11-12 · open the first message on its own page

Re: [PATCH] t0021, t5615: use $PWD instead of $(pwd) in PATH-like shell variables

From: Junio C Hamano <hidden>
Date: 2016-11-11 18:55:56

Johannes Sixt [off-list ref] writes:
We have to use $PWD instead of $(pwd) because on Windows the latter
would add a C: style path to bash's Unix-style $PATH variable, which
becomes confused by the colon after the drive letter. ($PWD is a
Unix-style path.)

In the case of GIT_ALTERNATE_OBJECT_DIRECTORIES, bash on Windows
assembles a Unix-style path list with the colon as separators. It
converts the value to a Windows-style path list with the semicolon as
path separator when it forwards the variable to git.exe. The same
confusion happens when bash's original value is contaminated with
Windows style paths.

Signed-off-by: Johannes Sixt <redacted>
---
Am 11.11.2016 um 18:11 schrieb Johannes Sixt:
quoted
Am 11.11.2016 um 18:06 schrieb Junio C Hamano:
quoted
Johannes Schindelin [off-list ref] writes:
...
When the MSYS program such as bash invokes a non-MSYS program, it
translates the Unix-style paths in arguments and environment variables
to Windows stlye. We only have to ensure that we inject only Unix-style
paths in these places so as not to confuse the conversion algorithm.
Most of the time, we do not have to worry.

On the other hand, when we write a path to a file that git.exe consumes
or receive a path from git.exe, i.e., when the path travels through
stdout and stdin, no automatic translation happens (which is quite
understandable), and we have do the translation explicitly. An example
for such a case is when we write a .git/info/alternates file via the
shell.
quoted
A simpler fix is to use $PWD instead of $(pwd). I'll submit a patch in a
moment.
Here it is. I had proposed the t0021 part earlier, but it fell through
the cracks during the temporary maintainer change.
Thanks.  Dscho, does this fix both of these issues to you?
quoted hunk
 t/t0021-conversion.sh    | 2 +-
 t/t5615-alternate-env.sh | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 9ff502773d..b93cd44546 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -4,7 +4,7 @@ test_description='blob conversion via gitattributes'
 
 . ./test-lib.sh
 
-TEST_ROOT="$(pwd)"
+TEST_ROOT="$PWD"
 PATH=$TEST_ROOT:$PATH
 
 write_script <<\EOF "$TEST_ROOT/rot13.sh"
diff --git a/t/t5615-alternate-env.sh b/t/t5615-alternate-env.sh
index 22d9d8178b..eec4137ca5 100755
--- a/t/t5615-alternate-env.sh
+++ b/t/t5615-alternate-env.sh
@@ -31,14 +31,14 @@ test_expect_success 'objects inaccessible without alternates' '
 '
 
 test_expect_success 'access alternate via absolute path' '
-	check_obj "$(pwd)/one.git/objects" <<-EOF
+	check_obj "$PWD/one.git/objects" <<-EOF
 	$one blob
 	$two missing
 	EOF
 '
 
 test_expect_success 'access multiple alternates' '
-	check_obj "$(pwd)/one.git/objects:$(pwd)/two.git/objects" <<-EOF
+	check_obj "$PWD/one.git/objects:$PWD/two.git/objects" <<-EOF
 	$one blob
 	$two blob
 	EOF

Re: [PATCH] t0021, t5615: use $PWD instead of $(pwd) in PATH-like shell variables

From: Johannes Schindelin <hidden>
Date: 2016-11-12 12:50:13

Hi Junio,

On Fri, 11 Nov 2016, Junio C Hamano wrote:
Johannes Sixt [off-list ref] writes:
quoted
We have to use $PWD instead of $(pwd) because on Windows the latter
would add a C: style path to bash's Unix-style $PATH variable, which
becomes confused by the colon after the drive letter. ($PWD is a
Unix-style path.)

In the case of GIT_ALTERNATE_OBJECT_DIRECTORIES, bash on Windows
assembles a Unix-style path list with the colon as separators. It
converts the value to a Windows-style path list with the semicolon as
path separator when it forwards the variable to git.exe. The same
confusion happens when bash's original value is contaminated with
Windows style paths.

Signed-off-by: Johannes Sixt <redacted>
---
Am 11.11.2016 um 18:11 schrieb Johannes Sixt:
quoted
Am 11.11.2016 um 18:06 schrieb Junio C Hamano:
quoted
Johannes Schindelin [off-list ref] writes:
...
When the MSYS program such as bash invokes a non-MSYS program, it
translates the Unix-style paths in arguments and environment variables
to Windows stlye. We only have to ensure that we inject only Unix-style
paths in these places so as not to confuse the conversion algorithm.
Most of the time, we do not have to worry.

On the other hand, when we write a path to a file that git.exe consumes
or receive a path from git.exe, i.e., when the path travels through
stdout and stdin, no automatic translation happens (which is quite
understandable), and we have do the translation explicitly. An example
for such a case is when we write a .git/info/alternates file via the
shell.
quoted
A simpler fix is to use $PWD instead of $(pwd). I'll submit a patch in a
moment.
Here it is. I had proposed the t0021 part earlier, but it fell through
the cracks during the temporary maintainer change.
Thanks.  Dscho, does this fix both of these issues to you?
Apparently it does because the CI jobs for `master` and for `next` pass.
The one for `pu` still times out, of course.

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help