]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7516-commit-races.sh
The third batch
[thirdparty/git.git] / t / t7516-commit-races.sh
1 #!/bin/sh
2
3 test_description='git commit races'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success 'race to create orphan commit' '
9 write_script hare-editor <<-\EOF &&
10 git commit --allow-empty -m hare
11 EOF
12 test_must_fail env EDITOR=./hare-editor git commit --allow-empty -m tortoise -e &&
13 git show -s --pretty=format:%s >subject &&
14 grep hare subject &&
15 git show -s --pretty=format:%P >out &&
16 test_must_be_empty out
17 '
18
19 test_expect_success 'race to create non-orphan commit' '
20 write_script airplane-editor <<-\EOF &&
21 git commit --allow-empty -m airplane
22 EOF
23 git checkout --orphan branch &&
24 git commit --allow-empty -m base &&
25 git rev-parse HEAD >base &&
26 test_must_fail env EDITOR=./airplane-editor git commit --allow-empty -m ship -e &&
27 git show -s --pretty=format:%s >subject &&
28 grep airplane subject &&
29 git rev-parse HEAD^ >parent &&
30 test_cmp base parent
31 '
32
33 test_done