]> git.ipfire.org Git - thirdparty/git.git/blob - t/t7516-commit-races.sh
test-lib-functions.sh: fix test_grep fail message wording
[thirdparty/git.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 git show -s --pretty=format:%P >out &&
14 test_must_be_empty out
15 '
16
17 test_expect_success 'race to create non-orphan commit' '
18 write_script airplane-editor <<-\EOF &&
19 git commit --allow-empty -m airplane
20 EOF
21 git checkout --orphan branch &&
22 git commit --allow-empty -m base &&
23 git rev-parse HEAD >base &&
24 test_must_fail env EDITOR=./airplane-editor git commit --allow-empty -m ship -e &&
25 git show -s --pretty=format:%s >subject &&
26 grep airplane subject &&
27 git rev-parse HEAD^ >parent &&
28 test_cmp base parent
29 '
30
31 test_done