Merge branch 'cl/config-regexp-docfix' into maint-2.46
[git/gitster.git] / t / t7516-commit-races.sh
blobbb95f09810b704b552352d90b6ec2a046c7d0fc1
1 #!/bin/sh
3 test_description='git commit races'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
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
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
33 test_done