interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t2015-checkout-unborn.sh

64 lines · 1487 bytes Raw Blame History
1#!/bin/sh
2
3test_description='checkout from unborn branch'
4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7. ./test-lib.sh
8
9test_expect_success 'setup' '
10 mkdir parent &&
11 (
12 cd parent &&
13 git init &&
14 echo content >file &&
15 git add file &&
16 git commit -m base
17 ) &&
18 git fetch parent main:origin
19'
20
21test_expect_success 'checkout from unborn preserves untracked files' '
22 echo precious >expect &&
23 echo precious >file &&
24 test_must_fail git checkout -b new origin &&
25 test_cmp expect file
26'
27
28test_expect_success 'checkout from unborn preserves index contents' '
29 echo precious >expect &&
30 echo precious >file &&
31 git add file &&
32 test_must_fail git checkout -b new origin &&
33 test_cmp expect file &&
34 git show :file >file &&
35 test_cmp expect file
36'
37
38test_expect_success 'checkout from unborn merges identical index contents' '
39 echo content >file &&
40 git add file &&
41 git checkout -b new origin
42'
43
44test_expect_success 'checking out another branch from unborn state' '
45 git checkout --orphan newroot &&
46 git checkout -b anothername &&
47 test_must_fail git show-ref --verify refs/heads/newroot &&
48 git symbolic-ref HEAD >actual &&
49 echo refs/heads/anothername >expect &&
50 test_cmp expect actual
51'
52
53test_expect_success 'checking out in a newly created repo' '
54 test_create_repo empty &&
55 (
56 cd empty &&
57 git symbolic-ref HEAD >expect &&
58 test_must_fail git checkout &&
59 git symbolic-ref HEAD >actual &&
60 test_cmp expect actual
61 )
62'
63
64test_done