threads / patch / 34291

patchlib-rebase: use write_script

Subject: [PATCH] lib-rebase: use write_script

## tl;dr

6 messages between Jun 27, 2013 and Jul 1, 2013. Diffs are folded; open one to read it.

replies: 5people: 2as markdown or json

Andrew Pimlott· Jun 27, 2013, 18:30 UTC · lore
Signed-off-by: Andrew Pimlott <andrew@pimlott.net>
---
 t/lib-rebase.sh |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Show changes to t/lib-rebase.sh +1 −3
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index 0b41155..7b42199 100644
--- a/t/lib-rebase.sh
+++ b/t/lib-rebase.sh
@@ -24,8 +24,7 @@
 #   ">" -- Add a blank line.
 
 set_fake_editor () {
-	echo "#!$SHELL_PATH" >fake-editor.sh
-	cat >> fake-editor.sh <<\EOF
+	write_script fake-editor.sh <<\EOF
 case "$1" in
 */COMMIT_EDITMSG)
 	test -z "$EXPECT_HEADER_COUNT" ||
@@ -65,7 +64,6 @@ cat "$1"
 EOF
 
 	test_set_editor "$(pwd)/fake-editor.sh"
-	chmod a+x fake-editor.sh
 }
 
 # After set_cat_todo_editor, rebase -i will write the todo list (ignoring
-- 
1.7.10.4
Junio C Hamano· Jun 27, 2013, 18:37 UTC · re: Andrew Pimlott · lore

Re: [PATCH] lib-rebase: use write_script

Andrew Pimlott <andrew@pimlott.net> writes:
Show 27 quoted lines
> Signed-off-by: Andrew Pimlott <andrew@pimlott.net>
> ---
>  t/lib-rebase.sh |    4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
> index 0b41155..7b42199 100644
> --- a/t/lib-rebase.sh
> +++ b/t/lib-rebase.sh
> @@ -24,8 +24,7 @@
>  #   ">" -- Add a blank line.
>  
>  set_fake_editor () {
> -	echo "#!$SHELL_PATH" >fake-editor.sh
> -	cat >> fake-editor.sh <<\EOF
> +	write_script fake-editor.sh <<\EOF
>  case "$1" in
>  */COMMIT_EDITMSG)
>  	test -z "$EXPECT_HEADER_COUNT" ||
> @@ -65,7 +64,6 @@ cat "$1"
>  EOF
>  
>  	test_set_editor "$(pwd)/fake-editor.sh"
> -	chmod a+x fake-editor.sh
>  }
>  
>  # After set_cat_todo_editor, rebase -i will write the todo list (ignoring
Thanks, but it should probably be
	write_script fake-editor.sh <<-\EOF
        case "$1" in
        ...
        EOF
        test_set_editor ...
if the aim is to modernize this part.
Andrew Pimlott· Jun 27, 2013, 19:02 UTC · re: Junio C Hamano · lore

Re: [PATCH] lib-rebase: use write_script

Excerpts from Junio C Hamano's message of Thu Jun 27 11:37:31 -0700 2013:
Show 10 quoted lines
> Thanks, but it should probably be
> 
>     write_script fake-editor.sh <<-\EOF
>         case "$1" in
>         ...
>         EOF
> 
>         test_set_editor ...
> 
> if the aim is to modernize this part.

Yes, the goal is to make that file consistently use the current practice. (My syntax highlighting doesn't like it, but...) I should update the function I introduced first. I will re-submit the rebase -i --autosquash patch and wait for acceptance before trying to fix other things.

Andrew
Junio C Hamano· Jun 27, 2013, 20:50 UTC · re: Andrew Pimlott · lore

Re: [PATCH] lib-rebase: use write_script

Andrew Pimlott <andrew@pimlott.net> writes:
> I should update the function I introduced first.  I will re-submit
> the rebase -i --autosquash patch and wait for acceptance before
> trying to fix other things.
Thanks.
Andrew Pimlott· Jul 1, 2013, 16:23 UTC · re: Junio C Hamano · lore

Re: [PATCH] lib-rebase: use write_script

Excerpts from Junio C Hamano's message of Thu Jun 27 13:50:45 -0700 2013:
Show 7 quoted lines
> Andrew Pimlott <andrew@pimlott.net> writes:
> 
> > I should update the function I introduced first.  I will re-submit
> > the rebase -i --autosquash patch and wait for acceptance before
> > trying to fix other things.
> 
> Thanks.

Applies on top of rebase -i patch already accepted. Mostly whitespace changes.

Thanks for your other help.
Andrew
---8<---
Subject: [PATCH] lib-rebase: style: use write_script, <<-\EOF
Signed-off-by: Andrew Pimlott <andrew@pimlott.net>
---
 t/lib-rebase.sh |   74 +++++++++++++++++++++++++++----------------------------
 1 file changed, 36 insertions(+), 38 deletions(-)
Show changes to t/lib-rebase.sh +36 −38
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index 7f119e2..8ff87fb 100644
--- a/t/lib-rebase.sh
+++ b/t/lib-rebase.sh
@@ -24,48 +24,46 @@
 #   ">" -- Add a blank line.
 
 set_fake_editor () {
-	echo "#!$SHELL_PATH" >fake-editor.sh
-	cat >> fake-editor.sh <<\EOF
-case "$1" in
-*/COMMIT_EDITMSG)
-	test -z "$EXPECT_HEADER_COUNT" ||
-		test "$EXPECT_HEADER_COUNT" = "$(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1")" ||
+	write_script fake-editor.sh <<-\EOF
+	case "$1" in
+	*/COMMIT_EDITMSG)
+		test -z "$EXPECT_HEADER_COUNT" ||
+			test "$EXPECT_HEADER_COUNT" = "$(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1")" ||
+			exit
+		test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
+		test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
 		exit
-	test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
-	test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
-	exit
-	;;
-esac
-test -z "$EXPECT_COUNT" ||
-	test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) ||
-	exit
-test -z "$FAKE_LINES" && exit
-grep -v '^#' < "$1" > "$1".tmp
-rm -f "$1"
-echo 'rebase -i script before editing:'
-cat "$1".tmp
-action=pick
-for line in $FAKE_LINES; do
-	case $line in
-	squash|fixup|edit|reword)
-		action="$line";;
-	exec*)
-		echo "$line" | sed 's/_/ /g' >> "$1";;
-	"#")
-		echo '# comment' >> "$1";;
-	">")
-		echo >> "$1";;
-	*)
-		sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1"
-		action=pick;;
+		;;
 	esac
-done
-echo 'rebase -i script after editing:'
-cat "$1"
-EOF
+	test -z "$EXPECT_COUNT" ||
+		test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) ||
+		exit
+	test -z "$FAKE_LINES" && exit
+	grep -v '^#' < "$1" > "$1".tmp
+	rm -f "$1"
+	echo 'rebase -i script before editing:'
+	cat "$1".tmp
+	action=pick
+	for line in $FAKE_LINES; do
+		case $line in
+		squash|fixup|edit|reword)
+			action="$line";;
+		exec*)
+			echo "$line" | sed 's/_/ /g' >> "$1";;
+		"#")
+			echo '# comment' >> "$1";;
+		">")
+			echo >> "$1";;
+		*)
+			sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1"
+			action=pick;;
+		esac
+	done
+	echo 'rebase -i script after editing:'
+	cat "$1"
+	EOF
 
 	test_set_editor "$(pwd)/fake-editor.sh"
-	chmod a+x fake-editor.sh
 }
 
 # After set_cat_todo_editor, rebase -i will write the todo list (ignoring
-- 
1.7.10.4

← back to recent threads