t / t2015-checkout-unborn.shon commit l10n: zh_CN: Revision for git v2.21.0 l10n (8e4e055)
   1#!/bin/sh
   2
   3test_description='checkout from unborn branch'
   4. ./test-lib.sh
   5
   6test_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
  15'
  16
  17test_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
  22'
  23
  24test_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
  32'
  33
  34test_expect_success 'checkout from unborn merges identical index contents' '
  35        echo content >file &&
  36        git add file &&
  37        git checkout -b new origin
  38'
  39
  40test_expect_success 'checking out another branch from unborn state' '
  41        git checkout --orphan newroot &&
  42        git checkout -b anothername &&
  43        test_must_fail git show-ref --verify refs/heads/newroot &&
  44        git symbolic-ref HEAD >actual &&
  45        echo refs/heads/anothername >expect &&
  46        test_cmp expect actual
  47'
  48
  49test_expect_success 'checking out in a newly created repo' '
  50        test_create_repo empty &&
  51        (
  52                cd empty &&
  53                git symbolic-ref HEAD >expect &&
  54                test_must_fail git checkout &&
  55                git symbolic-ref HEAD >actual &&
  56                test_cmp expect actual
  57        )
  58'
  59
  60test_done