Merge branch 'jc/merge-symlink-ours-theirs' into maint
[git] / t / t7516-commit-races.sh
1 #!/bin/sh
2
3 test_description='git commit races'
4 . ./test-lib.sh
5
6 test_expect_success 'race to create orphan commit' '
7         write_script hare-editor <<-\EOF &&
8         git commit --allow-empty -m hare
9         EOF
10         test_must_fail env EDITOR=./hare-editor git commit --allow-empty -m tortoise -e &&
11         git show -s --pretty=format:%s >subject &&
12         grep hare subject &&
13         test -z "$(git show -s --pretty=format:%P)"
14 '
15
16 test_expect_success 'race to create non-orphan commit' '
17         write_script airplane-editor <<-\EOF &&
18         git commit --allow-empty -m airplane
19         EOF
20         git checkout --orphan branch &&
21         git commit --allow-empty -m base &&
22         git rev-parse HEAD >base &&
23         test_must_fail env EDITOR=./airplane-editor git commit --allow-empty -m ship -e &&
24         git show -s --pretty=format:%s >subject &&
25         grep airplane subject &&
26         git rev-parse HEAD^ >parent &&
27         test_cmp base parent
28 '
29
30 test_done