]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3429-rebase-edit-todo.sh
Merge branch 'fc/remove-header-workarounds-for-asciidoc'
[thirdparty/git.git] / t / t3429-rebase-edit-todo.sh
CommitLineData
54fd3243
SH
1#!/bin/sh
2
3test_description='rebase should reread the todo file if an exec modifies it'
4
603f2f57 5TEST_PASSES_SANITIZE_LEAK=true
54fd3243 6. ./test-lib.sh
a47ba3c7
PW
7. "$TEST_DIRECTORY"/lib-rebase.sh
8
9test_expect_success 'setup' '
10 test_commit first file &&
11 test_commit second file &&
12 test_commit third file
13'
54fd3243
SH
14
15test_expect_success 'rebase exec modifies rebase-todo' '
54fd3243 16 todo=.git/rebase-merge/git-rebase-todo &&
cc9dcdee 17 git rebase HEAD~1 -x "echo exec touch F >>$todo" &&
54fd3243
SH
18 test -e F
19'
20
cc9dcdee
EN
21test_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
24'
25
440bf91d 26test_expect_success 'loose object cache vs re-reading todo list' '
26527ed8
JS
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
39
40 shift
41 test -z "$*" ||
42 echo "exec $0 $*" >>$GIT_REBASE_TODO
43 EOS
44
45 git rebase HEAD -x "./append-todo.sh 5 6"
46'
47
a47ba3c7
PW
48test_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
53
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
59'
60
befd4f6a
SG
61test_expect_success 're-reading todo doesnt interfere with revert --edit' '
62 git reset --hard third &&
63
64 git revert --edit third second &&
65
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
75'
76
77test_expect_success 're-reading todo doesnt interfere with cherry-pick --edit' '
78 git reset --hard first &&
79
80 git cherry-pick --edit second third &&
81
82 cat >expect <<-\EOF &&
83 third
84 second
85 first
86 EOF
87 git log --format="%s" >actual &&
88 test_cmp expect actual
89'
90
54fd3243 91test_done