Re: Re* [PATCH] git-remote-testgit: avoid process substitution

5 messages, 1 author, 2016-06-15 · open the first message on its own page

Re: Re* [PATCH] git-remote-testgit: avoid process substitution

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:03

Johannes Sixt [off-list ref] writes:
The patch below doesn't remove the bash dependency, yet, but it addresses
the problematic mismatch you noticed without the need for $LF. Can you
please queue it to move the topic forward?
I'll send three-patch series I have (including the two discussed in
the thread) on top of fc/transport-helper-error-reporting as a reply
to this message.  It seems to pass "make SHELL_PATH=/bin/dash test".

[PATCH 0/3] De-bashing remote-testgit

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:03

The two from J6t are what were discussed on the list.  The last one
is to teach git-remote-testgit to honor SHELL_PATH like all the
other shell scripts.

Johannes Sixt (2):
  git-remote-testgit: avoid process substitution
  git-remote-testgit: further remove some bashisms

Junio C Hamano (1):
  git-remote-testgit: build it to run under $SHELL_PATH

 .gitignore                                  |  1 +
 Makefile                                    |  1 +
 git-remote-testgit => git-remote-testgit.sh | 26 ++++++++++++++++----------
 t/t5801-remote-helpers.sh                   |  5 -----
 4 files changed, 18 insertions(+), 15 deletions(-)
 rename git-remote-testgit => git-remote-testgit.sh (77%)

-- 
1.8.3-rc0-121-gda9b90f

[PATCH 1/3] git-remote-testgit: avoid process substitution

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:03

From: Johannes Sixt <redacted>

The implementation of bash on Windows does not offer process substitution.

Signed-off-by: Johannes Sixt <redacted>
Signed-off-by: Junio C Hamano <redacted>
---
 git-remote-testgit | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/git-remote-testgit b/git-remote-testgit
index 5fd09f9..643e4ae 100755
--- a/git-remote-testgit
+++ b/git-remote-testgit
@@ -86,17 +86,18 @@ do
 			exit 1
 		fi
 
-		before=$(git for-each-ref --format='%(refname) %(objectname)')
+		before=$(git for-each-ref --format=' %(refname) %(objectname) ')
 
 		git fast-import "${testgitmarks_args[@]}" --quiet
 
-		after=$(git for-each-ref --format='%(refname) %(objectname)')
-
 		# figure out which refs were updated
-		join -e 0 -o '0 1.2 2.2' -a 2 <(echo "$before") <(echo "$after") |
-		while read ref a b
+		git for-each-ref --format='%(refname) %(objectname)' |
+		while read ref a
 		do
-			test $a == $b && continue
+			case "$before" in
+			*" $ref $a "*)
+				continue ;;	# unchanged
+			esac
 			echo "ok $ref"
 		done
 
-- 
1.8.3-rc0-121-gda9b90f

[PATCH 3/3] git-remote-testgit: build it to run under $SHELL_PATH

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:03

Just like all the other shell scripts, replace the shebang line to
make sure it runs under the shell the user specified.

As this no longer depends on bashisms, t5801 does not have to say
bash must be available somewhere on the system.

Signed-off-by: Junio C Hamano <redacted>
---
 .gitignore                                  | 1 +
 Makefile                                    | 1 +
 git-remote-testgit => git-remote-testgit.sh | 0
 t/t5801-remote-helpers.sh                   | 5 -----
 4 files changed, 2 insertions(+), 5 deletions(-)
 rename git-remote-testgit => git-remote-testgit.sh (100%)
diff --git a/.gitignore b/.gitignore
index 6669bf0..10aee94 100644
--- a/.gitignore
+++ b/.gitignore
@@ -125,6 +125,7 @@
 /git-remote-ftps
 /git-remote-fd
 /git-remote-ext
+/git-remote-testgit
 /git-remote-testpy
 /git-remote-testsvn
 /git-repack
diff --git a/Makefile b/Makefile
index 0f931a2..5f424a7 100644
--- a/Makefile
+++ b/Makefile
@@ -460,6 +460,7 @@ SCRIPT_SH += git-mergetool.sh
 SCRIPT_SH += git-pull.sh
 SCRIPT_SH += git-quiltimport.sh
 SCRIPT_SH += git-rebase.sh
+SCRIPT_SH += git-remote-testgit.sh
 SCRIPT_SH += git-repack.sh
 SCRIPT_SH += git-request-pull.sh
 SCRIPT_SH += git-stash.sh
diff --git a/git-remote-testgit b/git-remote-testgit.sh
similarity index 100%
rename from git-remote-testgit
rename to git-remote-testgit.sh
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index c956abd..0a83db8 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -7,11 +7,6 @@ test_description='Test remote-helper import and export commands'
 
 . ./test-lib.sh
 
-if ! type "${BASH-bash}" >/dev/null 2>&1; then
-	skip_all='skipping remote-testgit tests, bash not available'
-	test_done
-fi
-
 compare_refs() {
 	git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
 	git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
-- 
1.8.3-rc0-121-gda9b90f

[PATCH 2/3] git-remote-testgit: further remove some bashisms

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:04

From: Johannes Sixt <redacted>

Signed-off-by: Johannes Sixt <redacted>
---
 git-remote-testgit | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/git-remote-testgit b/git-remote-testgit
index 643e4ae..b528949 100755
--- a/git-remote-testgit
+++ b/git-remote-testgit
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/sh
 # Copyright (c) 2012 Felipe Contreras
 
 alias=$1
@@ -23,7 +23,6 @@ then
 	testgitmarks="$dir/testgit.marks"
 	test -e "$gitmarks" || >"$gitmarks"
 	test -e "$testgitmarks" || >"$testgitmarks"
-	testgitmarks_args=( "--"{import,export}"-marks=$testgitmarks" )
 fi
 
 while read line
@@ -69,7 +68,10 @@ do
 		fi
 
 		echo "feature done"
-		git fast-export "${testgitmarks_args[@]}" $refs |
+		git fast-export \
+			${testgitmarks:+"--import-marks=$testgitmarks"} \
+			${testgitmarks:+"--export-marks=$testgitmarks"} \
+			$refs |
 		sed -e "s#refs/heads/#${prefix}/heads/#g"
 		echo "done"
 		;;
@@ -88,7 +90,10 @@ do
 
 		before=$(git for-each-ref --format=' %(refname) %(objectname) ')
 
-		git fast-import "${testgitmarks_args[@]}" --quiet
+		git fast-import \
+			${testgitmarks:+"--import-marks=$testgitmarks"} \
+			${testgitmarks:+"--export-marks=$testgitmarks"} \
+			--quiet
 
 		# figure out which refs were updated
 		git for-each-ref --format='%(refname) %(objectname)' |
-- 
1.8.3-rc0-121-gda9b90f
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help