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