backmerge a few more fixes to 1.7.1.X series
[git.git] / t / t2015-checkout-unborn.sh
blobc551d39a66c19514e260a7c938b840ce2870d45a
1 #!/bin/sh
3 test_description='checkout from unborn branch protects contents'
4 . ./test-lib.sh
6 test_expect_success 'setup' '
7 mkdir parent &&
8 (cd parent &&
9 git init &&
10 echo content >file &&
11 git add file &&
12 git commit -m base
13 ) &&
14 git fetch parent master:origin
17 test_expect_success 'checkout from unborn preserves untracked files' '
18 echo precious >expect &&
19 echo precious >file &&
20 test_must_fail git checkout -b new origin &&
21 test_cmp expect file
24 test_expect_success 'checkout from unborn preserves index contents' '
25 echo precious >expect &&
26 echo precious >file &&
27 git add file &&
28 test_must_fail git checkout -b new origin &&
29 test_cmp expect file &&
30 git show :file >file &&
31 test_cmp expect file
34 test_expect_success 'checkout from unborn merges identical index contents' '
35 echo content >file &&
36 git add file &&
37 git checkout -b new origin
40 test_done