diff options
Diffstat (limited to 'third_party/git/t/lib-rebase.sh')
-rw-r--r-- | third_party/git/t/lib-rebase.sh | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/third_party/git/t/lib-rebase.sh b/third_party/git/t/lib-rebase.sh index 7ea30e50068b..b72c051f4761 100644 --- a/third_party/git/t/lib-rebase.sh +++ b/third_party/git/t/lib-rebase.sh @@ -44,10 +44,10 @@ set_fake_editor () { rm -f "$1" echo 'rebase -i script before editing:' cat "$1".tmp - action=pick + action=\& for line in $FAKE_LINES; do case $line in - pick|p|squash|s|fixup|f|edit|e|reword|r|drop|d) + pick|p|squash|s|fixup|f|edit|e|reword|r|drop|d|label|l|reset|r|merge|m) action="$line";; exec_*|x_*|break|b) echo "$line" | sed 's/_/ /g' >> "$1";; @@ -58,11 +58,12 @@ set_fake_editor () { bad) action="badcmd";; fakesha) + test \& != "$action" || action=pick echo "$action XXXXXXX False commit" >> "$1" action=pick;; *) - sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1" - action=pick;; + sed -n "${line}s/^[a-z][a-z]*/$action/p" < "$1".tmp >> "$1" + action=\&;; esac done echo 'rebase -i script after editing:' @@ -118,3 +119,31 @@ make_empty () { git commit --allow-empty -m "$1" && git tag "$1" } + +# Call this (inside test_expect_success) at the end of a test file to +# check that no tests have changed editor related environment +# variables or config settings +test_editor_unchanged () { + # We're only interested in exported variables hence 'sh -c' + sh -c 'cat >actual <<-EOF + EDITOR=$EDITOR + FAKE_COMMIT_AMEND=$FAKE_COMMIT_AMEND + FAKE_COMMIT_MESSAGE=$FAKE_COMMIT_MESSAGE + FAKE_LINES=$FAKE_LINES + GIT_EDITOR=$GIT_EDITOR + GIT_SEQUENCE_EDITOR=$GIT_SEQUENCE_EDITOR + core.editor=$(git config core.editor) + sequence.editor=$(git config sequence.editor) + EOF' + cat >expect <<-\EOF + EDITOR=: + FAKE_COMMIT_AMEND= + FAKE_COMMIT_MESSAGE= + FAKE_LINES= + GIT_EDITOR= + GIT_SEQUENCE_EDITOR= + core.editor= + sequence.editor= + EOF + test_cmp expect actual +} |