Start the 2.46 cycle
[git.git] / t / t3429-rebase-edit-todo.sh
blob8e0d03969a2fec13fba015158b3380ec2ee37c42
1 #!/bin/sh
3 test_description='rebase should reread the todo file if an exec modifies it'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-rebase.sh
9 test_expect_success 'setup' '
10 test_commit first file &&
11 test_commit second file &&
12 test_commit third file
15 test_expect_success 'rebase exec modifies rebase-todo' '
16 todo=.git/rebase-merge/git-rebase-todo &&
17 git rebase HEAD~1 -x "echo exec touch F >>$todo" &&
18 test -e F
21 test_expect_success 'rebase exec with an empty list does not exec anything' '
22 git rebase HEAD -x "true" 2>output &&
23 ! grep "Executing: true" output
26 test_expect_success 'loose object cache vs re-reading todo list' '
27 GIT_REBASE_TODO=.git/rebase-merge/git-rebase-todo &&
28 export GIT_REBASE_TODO &&
29 write_script append-todo.sh <<-\EOS &&
30 # For values 5 and 6, this yields SHA-1s with the same first two digits
31 echo "pick $(git rev-parse --short \
32 $(printf "%s\\n" \
33 "tree $EMPTY_TREE" \
34 "author A U Thor <author@example.org> $1 +0000" \
35 "committer A U Thor <author@example.org> $1 +0000" \
36 "" \
37 "$1" |
38 git hash-object -t commit -w --stdin))" >>$GIT_REBASE_TODO
40 shift
41 test -z "$*" ||
42 echo "exec $0 $*" >>$GIT_REBASE_TODO
43 EOS
45 git rebase HEAD -x "./append-todo.sh 5 6"
48 test_expect_success 'todo is re-read after reword and squash' '
49 write_script reword-editor.sh <<-\EOS &&
50 GIT_SEQUENCE_EDITOR="echo \"exec echo $(cat file) >>actual\" >>" \
51 git rebase --edit-todo
52 EOS
54 test_write_lines first third >expected &&
55 set_fake_editor &&
56 GIT_SEQUENCE_EDITOR="$EDITOR" FAKE_LINES="reword 1 squash 2 fixup 3" \
57 GIT_EDITOR=./reword-editor.sh git rebase -i --root third &&
58 test_cmp expected actual
61 test_expect_success 're-reading todo doesnt interfere with revert --edit' '
62 git reset --hard third &&
64 git revert --edit third second &&
66 cat >expect <<-\EOF &&
67 Revert "second"
68 Revert "third"
69 third
70 second
71 first
72 EOF
73 git log --format="%s" >actual &&
74 test_cmp expect actual
77 test_expect_success 're-reading todo doesnt interfere with cherry-pick --edit' '
78 git reset --hard first &&
80 git cherry-pick --edit second third &&
82 cat >expect <<-\EOF &&
83 third
84 second
85 first
86 EOF
87 git log --format="%s" >actual &&
88 test_cmp expect actual
91 test_done