]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3438-rebase-broken-files.sh
Merge branch 'rj/add-p-explicit-reshow'
[thirdparty/git.git] / t / t3438-rebase-broken-files.sh
1 #!/bin/sh
2
3 test_description='rebase behavior when on-disk files are broken'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success 'set up conflicting branches' '
9 test_commit base file &&
10 git checkout -b branch1 &&
11 test_commit one file &&
12 git checkout -b branch2 HEAD^ &&
13 test_commit two file
14 '
15
16 create_conflict () {
17 test_when_finished "git rebase --abort" &&
18 git checkout -B tmp branch2 &&
19 test_must_fail git rebase branch1
20 }
21
22 check_resolve_fails () {
23 echo resolved >file &&
24 git add file &&
25 test_must_fail git rebase --continue
26 }
27
28 for item in NAME EMAIL DATE
29 do
30 test_expect_success "detect missing GIT_AUTHOR_$item" '
31 create_conflict &&
32
33 grep -v $item .git/rebase-merge/author-script >tmp &&
34 mv tmp .git/rebase-merge/author-script &&
35
36 check_resolve_fails
37 '
38 done
39
40 for item in NAME EMAIL DATE
41 do
42 test_expect_success "detect duplicate GIT_AUTHOR_$item" '
43 create_conflict &&
44
45 grep -i $item .git/rebase-merge/author-script >tmp &&
46 cat tmp >>.git/rebase-merge/author-script &&
47
48 check_resolve_fails
49 '
50 done
51
52 test_expect_success 'unknown key in author-script' '
53 create_conflict &&
54
55 echo "GIT_AUTHOR_BOGUS=${SQ}whatever${SQ}" \
56 >>.git/rebase-merge/author-script &&
57
58 check_resolve_fails
59 '
60
61 test_expect_success POSIXPERM,SANITY 'unwritable rebased-patches does not leak' '
62 >.git/rebased-patches &&
63 chmod a-w .git/rebased-patches &&
64
65 git checkout -b side HEAD^ &&
66 test_commit unrelated &&
67 test_must_fail git rebase --apply --onto tmp HEAD^
68 '
69
70 test_done