summaryrefslogtreecommitdiff
path: root/t/t3436-rebase-more-options.sh
diff options
context:
space:
mode:
authorRohit Ashiwal <rohit.ashiwal265@gmail.com>2020-07-13 10:10:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-07-13 14:55:37 (GMT)
commitef484add9f6ba846c62e4f13ebe0ba99b9cc4aa5 (patch)
tree9255aed9eecbd45b7df914b6a5e2e0808bb70044 /t/t3436-rebase-more-options.sh
parent048abe1751e6727bfbacf7b80466d78e04631f94 (diff)
downloadgit-ef484add9f6ba846c62e4f13ebe0ba99b9cc4aa5.zip
git-ef484add9f6ba846c62e4f13ebe0ba99b9cc4aa5.tar.gz
git-ef484add9f6ba846c62e4f13ebe0ba99b9cc4aa5.tar.bz2
rebase -i: add --ignore-whitespace flag
Rebase is implemented with two different backends - 'apply' and 'merge' each of which support a different set of options. In particular the apply backend supports a number of options implemented by 'git am' that are not implemented in the merge backend. This means that the available options are different depending on which backend is used which is confusing. This patch adds support for the --ignore-whitespace option to the merge backend. This option treats lines with only whitespace changes as unchanged and is implemented in the merge backend by translating it to -Xignore-space-change. Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3436-rebase-more-options.sh')
-rwxr-xr-xt/t3436-rebase-more-options.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh
new file mode 100755
index 0000000..4f8a6e5
--- /dev/null
+++ b/t/t3436-rebase-more-options.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# Copyright (c) 2019 Rohit Ashiwal
+#
+
+test_description='tests to ensure compatibility between am and interactive backends'
+
+. ./test-lib.sh
+
+. "$TEST_DIRECTORY"/lib-rebase.sh
+
+# This is a special case in which both am and interactive backends
+# provide the same output. It was done intentionally because
+# both the backends fall short of optimal behaviour.
+test_expect_success 'setup' '
+ git checkout -b topic &&
+ test_write_lines "line 1" " line 2" "line 3" >file &&
+ git add file &&
+ git commit -m "add file" &&
+
+ test_write_lines "line 1" "new line 2" "line 3" >file &&
+ git commit -am "update file" &&
+ git tag side &&
+
+ git checkout --orphan master &&
+ test_write_lines "line 1" " line 2" "line 3" >file &&
+ git commit -am "add file" &&
+ git tag main
+'
+
+test_expect_success '--ignore-whitespace works with apply backend' '
+ test_must_fail git rebase --apply main side &&
+ git rebase --abort &&
+ git rebase --apply --ignore-whitespace main side &&
+ git diff --exit-code side
+'
+
+test_expect_success '--ignore-whitespace works with merge backend' '
+ test_must_fail git rebase --merge main side &&
+ git rebase --abort &&
+ git rebase --merge --ignore-whitespace main side &&
+ git diff --exit-code side
+'
+
+test_expect_success '--ignore-whitespace is remembered when continuing' '
+ (
+ set_fake_editor &&
+ FAKE_LINES="break 1" git rebase -i --ignore-whitespace \
+ main side &&
+ git rebase --continue
+ ) &&
+ git diff --exit-code side
+'
+
+# This must be the last test in this file
+test_expect_success '$EDITOR and friends are unchanged' '
+ test_editor_unchanged
+'
+
+test_done