]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t3416: set $EDITOR in subshell
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Mon, 17 Oct 2022 13:17:39 +0000 (13:17 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Oct 2022 18:45:09 +0000 (11:45 -0700)
As $EDITOR is exported, setting it in one test affects all subsequent
tests. Avoid this by always setting it in a subshell. Also remove a
couple of unnecessary call to set_fake_editor where the editor does
not change the todo list.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3416-rebase-onto-threedots.sh

index dc67d2308f36a0648d14e2c77de2b109145033d7..01eb9513d6c2d7c142e71bfb54d4d9454be180e7 100755 (executable)
@@ -79,8 +79,10 @@ test_expect_success 'rebase -i --onto main...topic' '
        git reset --hard &&
        git checkout topic &&
        git reset --hard G &&
-       set_fake_editor &&
-       EXPECT_COUNT=1 git rebase -i --onto main...topic F &&
+       (
+               set_fake_editor &&
+               EXPECT_COUNT=1 git rebase -i --onto main...topic F
+       ) &&
        git rev-parse HEAD^1 >actual &&
        git rev-parse C^0 >expect &&
        test_cmp expect actual
@@ -90,8 +92,10 @@ test_expect_success 'rebase -i --onto main...' '
        git reset --hard &&
        git checkout topic &&
        git reset --hard G &&
-       set_fake_editor &&
-       EXPECT_COUNT=1 git rebase -i --onto main... F &&
+       (
+               set_fake_editor &&
+               EXPECT_COUNT=1 git rebase -i --onto main... F
+       ) &&
        git rev-parse HEAD^1 >actual &&
        git rev-parse C^0 >expect &&
        test_cmp expect actual
@@ -102,7 +106,6 @@ test_expect_success 'rebase --onto main...side requires a single merge-base' '
        git checkout side &&
        git reset --hard K &&
 
-       set_fake_editor &&
        test_must_fail git rebase -i --onto main...side J 2>err &&
        grep "need exactly one merge base" err
 '
@@ -157,8 +160,10 @@ test_expect_success 'rebase -i --keep-base main from topic' '
        git checkout topic &&
        git reset --hard G &&
 
-       set_fake_editor &&
-       EXPECT_COUNT=2 git rebase -i --keep-base main &&
+       (
+               set_fake_editor &&
+               EXPECT_COUNT=2 git rebase -i --keep-base main
+       ) &&
        git rev-parse C >base.expect &&
        git merge-base main HEAD >base.actual &&
        test_cmp base.expect base.actual &&
@@ -172,8 +177,10 @@ test_expect_success 'rebase -i --keep-base main topic from main' '
        git checkout main &&
        git branch -f topic G &&
 
-       set_fake_editor &&
-       EXPECT_COUNT=2 git rebase -i --keep-base main topic &&
+       (
+               set_fake_editor &&
+               EXPECT_COUNT=2 git rebase -i --keep-base main topic
+       ) &&
        git rev-parse C >base.expect &&
        git merge-base main HEAD >base.actual &&
        test_cmp base.expect base.actual &&
@@ -188,9 +195,13 @@ test_expect_success 'rebase --keep-base requires a single merge base' '
        git checkout side &&
        git reset --hard K &&
 
-       set_fake_editor &&
        test_must_fail git rebase -i --keep-base main 2>err &&
        grep "need exactly one merge base with branch" err
 '
 
+# This must be the last test in this file
+test_expect_success '$EDITOR and friends are unchanged' '
+       test_editor_unchanged
+'
+
 test_done