t / t3203-branch-output.shon commit Merge branch 'jl/submodule-update-quiet' (86c9cd8)
   1#!/bin/sh
   2
   3test_description='git branch display tests'
   4. ./test-lib.sh
   5
   6test_expect_success 'make commits' '
   7        echo content >file &&
   8        git add file &&
   9        git commit -m one &&
  10        echo content >>file &&
  11        git commit -a -m two
  12'
  13
  14test_expect_success 'make branches' '
  15        git branch branch-one &&
  16        git branch branch-two HEAD^
  17'
  18
  19test_expect_success 'make remote branches' '
  20        git update-ref refs/remotes/origin/branch-one branch-one &&
  21        git update-ref refs/remotes/origin/branch-two branch-two &&
  22        git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/branch-one
  23'
  24
  25cat >expect <<'EOF'
  26  branch-one
  27  branch-two
  28* master
  29EOF
  30test_expect_success 'git branch shows local branches' '
  31        git branch >actual &&
  32        test_cmp expect actual
  33'
  34
  35cat >expect <<'EOF'
  36  origin/HEAD -> origin/branch-one
  37  origin/branch-one
  38  origin/branch-two
  39EOF
  40test_expect_success 'git branch -r shows remote branches' '
  41        git branch -r >actual &&
  42        test_cmp expect actual
  43'
  44
  45cat >expect <<'EOF'
  46  branch-one
  47  branch-two
  48* master
  49  remotes/origin/HEAD -> origin/branch-one
  50  remotes/origin/branch-one
  51  remotes/origin/branch-two
  52EOF
  53test_expect_success 'git branch -a shows local and remote branches' '
  54        git branch -a >actual &&
  55        test_cmp expect actual
  56'
  57
  58cat >expect <<'EOF'
  59two
  60one
  61two
  62EOF
  63test_expect_success 'git branch -v shows branch summaries' '
  64        git branch -v >tmp &&
  65        awk "{print \$NF}" <tmp >actual &&
  66        test_cmp expect actual
  67'
  68
  69cat >expect <<'EOF'
  70* (no branch)
  71  branch-one
  72  branch-two
  73  master
  74EOF
  75test_expect_success 'git branch shows detached HEAD properly' '
  76        git checkout HEAD^0 &&
  77        git branch >actual &&
  78        test_i18ncmp expect actual
  79'
  80
  81test_done