Jeff King | 0afc304 | 2009-02-18 22:34:44 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git branch display tests' |
| 4 | . ./test-lib.sh |
| 5 | |
| 6 | test_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 | |
| 14 | test_expect_success 'make branches' ' |
Jonathan Nieder | a48fcd8 | 2010-10-30 20:46:54 -0500 | [diff] [blame] | 15 | git branch branch-one && |
Jeff King | 0afc304 | 2009-02-18 22:34:44 -0500 | [diff] [blame] | 16 | git branch branch-two HEAD^ |
| 17 | ' |
| 18 | |
| 19 | test_expect_success 'make remote branches' ' |
Jonathan Nieder | a48fcd8 | 2010-10-30 20:46:54 -0500 | [diff] [blame] | 20 | git update-ref refs/remotes/origin/branch-one branch-one && |
| 21 | git update-ref refs/remotes/origin/branch-two branch-two && |
Jeff King | 0afc304 | 2009-02-18 22:34:44 -0500 | [diff] [blame] | 22 | git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/branch-one |
| 23 | ' |
| 24 | |
| 25 | cat >expect <<'EOF' |
| 26 | branch-one |
| 27 | branch-two |
| 28 | * master |
| 29 | EOF |
| 30 | test_expect_success 'git branch shows local branches' ' |
| 31 | git branch >actual && |
| 32 | test_cmp expect actual |
| 33 | ' |
| 34 | |
Michael J Gruber | cddd127 | 2011-08-28 16:54:31 +0200 | [diff] [blame] | 35 | test_expect_success 'git branch --list shows local branches' ' |
| 36 | git branch --list >actual && |
| 37 | test_cmp expect actual |
| 38 | ' |
| 39 | |
Jeff King | 0afc304 | 2009-02-18 22:34:44 -0500 | [diff] [blame] | 40 | cat >expect <<'EOF' |
Michael J Gruber | d8d3373 | 2011-08-28 16:54:32 +0200 | [diff] [blame] | 41 | branch-one |
| 42 | branch-two |
| 43 | EOF |
| 44 | test_expect_success 'git branch --list pattern shows matching local branches' ' |
| 45 | git branch --list branch* >actual && |
| 46 | test_cmp expect actual |
| 47 | ' |
| 48 | |
| 49 | cat >expect <<'EOF' |
Jeff King | 0afc304 | 2009-02-18 22:34:44 -0500 | [diff] [blame] | 50 | origin/HEAD -> origin/branch-one |
| 51 | origin/branch-one |
| 52 | origin/branch-two |
| 53 | EOF |
| 54 | test_expect_success 'git branch -r shows remote branches' ' |
| 55 | git branch -r >actual && |
| 56 | test_cmp expect actual |
| 57 | ' |
| 58 | |
| 59 | cat >expect <<'EOF' |
| 60 | branch-one |
| 61 | branch-two |
| 62 | * master |
| 63 | remotes/origin/HEAD -> origin/branch-one |
| 64 | remotes/origin/branch-one |
| 65 | remotes/origin/branch-two |
| 66 | EOF |
| 67 | test_expect_success 'git branch -a shows local and remote branches' ' |
| 68 | git branch -a >actual && |
| 69 | test_cmp expect actual |
| 70 | ' |
| 71 | |
| 72 | cat >expect <<'EOF' |
| 73 | two |
| 74 | one |
| 75 | two |
| 76 | EOF |
| 77 | test_expect_success 'git branch -v shows branch summaries' ' |
| 78 | git branch -v >tmp && |
| 79 | awk "{print \$NF}" <tmp >actual && |
| 80 | test_cmp expect actual |
| 81 | ' |
| 82 | |
| 83 | cat >expect <<'EOF' |
Michael J Gruber | d8d3373 | 2011-08-28 16:54:32 +0200 | [diff] [blame] | 84 | two |
| 85 | one |
| 86 | EOF |
Michael J Gruber | 7b787599 | 2011-09-08 14:09:50 -0700 | [diff] [blame] | 87 | test_expect_success 'git branch --list -v pattern shows branch summaries' ' |
| 88 | git branch --list -v branch* >tmp && |
Michael J Gruber | d8d3373 | 2011-08-28 16:54:32 +0200 | [diff] [blame] | 89 | awk "{print \$NF}" <tmp >actual && |
| 90 | test_cmp expect actual |
| 91 | ' |
| 92 | |
Michael J Gruber | 7b787599 | 2011-09-08 14:09:50 -0700 | [diff] [blame] | 93 | test_expect_success 'git branch -v pattern does not show branch summaries' ' |
| 94 | test_must_fail git branch -v branch* |
| 95 | ' |
| 96 | |
Michael J Gruber | d8d3373 | 2011-08-28 16:54:32 +0200 | [diff] [blame] | 97 | cat >expect <<'EOF' |
Jeff King | 0afc304 | 2009-02-18 22:34:44 -0500 | [diff] [blame] | 98 | * (no branch) |
| 99 | branch-one |
| 100 | branch-two |
| 101 | master |
| 102 | EOF |
Junio C Hamano | fff1bb3 | 2011-04-12 16:23:01 -0700 | [diff] [blame] | 103 | test_expect_success 'git branch shows detached HEAD properly' ' |
Jeff King | 0afc304 | 2009-02-18 22:34:44 -0500 | [diff] [blame] | 104 | git checkout HEAD^0 && |
| 105 | git branch >actual && |
Junio C Hamano | fff1bb3 | 2011-04-12 16:23:01 -0700 | [diff] [blame] | 106 | test_i18ncmp expect actual |
Jeff King | 0afc304 | 2009-02-18 22:34:44 -0500 | [diff] [blame] | 107 | ' |
| 108 | |
| 109 | test_done |