git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 12, 2013, 18:00 UTC
Message-ID
<7vvc9xh0p1.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7v4nhhigp5.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 17 quoted lines
>>  	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)
 '
Previous: Junio C HamanoNext: John Keeping
Message 11 of 13 in “rebase -i: respect core.commentchar”
  1. rebase -i: respect core.commentcharJohn Keeping, Feb 11, 2013
  2. Junio C HamanoFeb 11, 2013
  3. John KeepingFeb 11, 2013
  4. Junio C HamanoFeb 11, 2013
  5. rebase -i: respect core.commentcharJohn Keeping, Feb 11, 2013
  6. Junio C HamanoFeb 12, 2013
  7. John KeepingFeb 12, 2013
  8. Junio C HamanoFeb 12, 2013
  9. John KeepingFeb 12, 2013
  10. Junio C HamanoFeb 12, 2013
  11. Junio C HamanoFeb 12, 2013
  12. John KeepingFeb 12, 2013
  13. Junio C HamanoFeb 12, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.