Thread (2 messages) 2 messages, 2 authors, 2016-06-15

Re: [PATCH v2] rebase -i: respect core.commentchar

flat view

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:56:08
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Junio C Hamano [off-list ref] writes:
quoted
 	cat >comment-lines.sh <<EOF &&
 #!$SHELL_PATH
-sed -e "2,\$ s/^/\\\\\\/" "\$1" >"\$1".tmp
+sed -e "2,\$ s/^/\\\\\\\\/" "\$1" >"\$1".tmp
 mv "\$1".tmp "\$1"
 EOF
 	chmod a+x comment-lines.sh &&
Yeek.  If you used write_script with here-text that does not
interpolate,

	write_script remove-all-but-the-first.sh <<\EOF
	sed -e '2,$s/^/\\/'  <"$1" >"$1.tmp" &&
        mv "$1.tmp" "$1"
	EOF

the above would be much more readable.
As this is already inside a pair of '', we cannot use single quote
around sed expression without doing the ugly '\''.

So it needs to be more like this, and I think it still is more
readable.
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index cbe36bf..8b3e2cd 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -945,13 +945,11 @@ test_expect_success 'rebase -i respects core.commentchar' '
 	git checkout E^0 &&
 	git config core.commentchar "\\" &&
 	test_when_finished "git config --unset core.commentchar" &&
-	cat >comment-lines.sh <<EOF &&
-#!$SHELL_PATH
-sed -e "2,\$ s/^/\\\\\\/" "\$1" >"\$1".tmp
-mv "\$1".tmp "\$1"
-EOF
-	chmod a+x comment-lines.sh &&
-	test_set_editor "$(pwd)/comment-lines.sh" &&
+	write_script remove-all-but-first.sh <<-\EOF &&
+	sed -e "2,\$s/^/\\\\/" "$1" >"$1.tmp" &&
+	mv "$1.tmp" "$1"
+	EOF
+	test_set_editor "$(pwd)/remove-all-but-first.sh" &&
 	git rebase -i B &&
 	test B = $(git cat-file commit HEAD^ | sed -ne \$p)
 '
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help