]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3429-rebase-edit-todo.sh
Merge branch 'bc/sha-256-part-2'
[thirdparty/git.git] / t / t3429-rebase-edit-todo.sh
1 #!/bin/sh
2
3 test_description='rebase should reread the todo file if an exec modifies it'
4
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-rebase.sh
7
8 test_expect_success 'setup' '
9 test_commit first file &&
10 test_commit second file &&
11 test_commit third file
12 '
13
14 test_expect_success 'rebase exec modifies rebase-todo' '
15 todo=.git/rebase-merge/git-rebase-todo &&
16 git rebase HEAD -x "echo exec touch F >>$todo" &&
17 test -e F
18 '
19
20 test_expect_success 'loose object cache vs re-reading todo list' '
21 GIT_REBASE_TODO=.git/rebase-merge/git-rebase-todo &&
22 export GIT_REBASE_TODO &&
23 write_script append-todo.sh <<-\EOS &&
24 # For values 5 and 6, this yields SHA-1s with the same first two digits
25 echo "pick $(git rev-parse --short \
26 $(printf "%s\\n" \
27 "tree $EMPTY_TREE" \
28 "author A U Thor <author@example.org> $1 +0000" \
29 "committer A U Thor <author@example.org> $1 +0000" \
30 "" \
31 "$1" |
32 git hash-object -t commit -w --stdin))" >>$GIT_REBASE_TODO
33
34 shift
35 test -z "$*" ||
36 echo "exec $0 $*" >>$GIT_REBASE_TODO
37 EOS
38
39 git rebase HEAD -x "./append-todo.sh 5 6"
40 '
41
42 test_expect_success 'todo is re-read after reword and squash' '
43 write_script reword-editor.sh <<-\EOS &&
44 GIT_SEQUENCE_EDITOR="echo \"exec echo $(cat file) >>actual\" >>" \
45 git rebase --edit-todo
46 EOS
47
48 test_write_lines first third >expected &&
49 set_fake_editor &&
50 GIT_SEQUENCE_EDITOR="$EDITOR" FAKE_LINES="reword 1 squash 2 fixup 3" \
51 GIT_EDITOR=./reword-editor.sh git rebase -i --root third &&
52 test_cmp expected actual
53 '
54
55 test_expect_success 're-reading todo doesnt interfere with revert --edit' '
56 git reset --hard third &&
57
58 git revert --edit third second &&
59
60 cat >expect <<-\EOF &&
61 Revert "second"
62 Revert "third"
63 third
64 second
65 first
66 EOF
67 git log --format="%s" >actual &&
68 test_cmp expect actual
69 '
70
71 test_expect_success 're-reading todo doesnt interfere with cherry-pick --edit' '
72 git reset --hard first &&
73
74 git cherry-pick --edit second third &&
75
76 cat >expect <<-\EOF &&
77 third
78 second
79 first
80 EOF
81 git log --format="%s" >actual &&
82 test_cmp expect actual
83 '
84
85 test_done