]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/lib-rebase.sh: support explicit 'pick' commands in 'fake_editor.sh'
authorSZEDER Gábor <szeder.dev@gmail.com>
Thu, 23 Aug 2018 10:09:15 +0000 (12:09 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Aug 2018 16:23:34 +0000 (09:23 -0700)
The verbose output of the test 'reword without issues functions as
intended' in 't3423-rebase-reword.sh', added in a9279c6785 (sequencer:
do not squash 'reword' commits when we hit conflicts, 2018-06-19),
contains the following error output:

  sed: -e expression #1, char 2: extra characters after command

This error comes from within the 'fake-editor.sh' script created by
'lib-rebase.sh's set_fake_editor() function, and the root cause is the
FAKE_LINES="pick 1 reword 2" variable in the test in question, in
particular the "pick" word.  'fake-editor.sh' assumes 'pick' to be the
default rebase command and doesn't support an explicit 'pick' command
in FAKE_LINES.  As a result, 'pick' will be used instead of a line
number when assembling the following 'sed' script:

  sed -n picks/^pick/pick/p

which triggers the aforementioned error.

Luckily, this didn't affect the test's correctness: the erroring 'sed'
command doesn't write anything to the todo script, and processing the
rest of FAKE_LINES generates the desired todo script, as if that
'pick' command were not there at all.

The minimal fix would be to remove the 'pick' word from FAKE_LINES,
but that would leave us susceptible to similar issues in the future.

Instead, teach the fake-editor script to recognize an explicit 'pick'
command, which is still a fairly trivial change.

In the future we might want to consider reinforcing this fake editor
script with an &&-chain and stricter parsing of the FAKE_LINES
variable (e.g. to error out when encountering unknown rebase commands
or commands and line numbers in the wrong order).

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-rebase.sh

index 25a77ee5cb04088297b7d9fd93d04d76e1494875..2ca9fb69d62083494869fff6420eec39834b2eb4 100644 (file)
@@ -14,8 +14,8 @@
 #       specified line.
 #
 #   "<cmd> <lineno>" -- add a line with the specified command
-#       ("squash", "fixup", "edit", "reword" or "drop") and the SHA1 taken
-#       from the specified line.
+#       ("pick", "squash", "fixup", "edit", "reword" or "drop") and the
+#       SHA1 taken from the specified line.
 #
 #   "exec_cmd_with_args" -- add an "exec cmd with args" line.
 #
@@ -47,7 +47,7 @@ set_fake_editor () {
        action=pick
        for line in $FAKE_LINES; do
                case $line in
-               squash|fixup|edit|reword|drop)
+               pick|squash|fixup|edit|reword|drop)
                        action="$line";;
                exec*)
                        echo "$line" | sed 's/_/ /g' >> "$1";;