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