]>
Commit | Line | Data |
---|---|---|
c0234b2e JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='remote tracking stats' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | advance () { | |
8 | echo "$1" >"$1" && | |
9 | git add "$1" && | |
10 | test_tick && | |
11 | git commit -m "$1" | |
12 | } | |
13 | ||
14 | test_expect_success setup ' | |
15 | for i in a b c; | |
16 | do | |
17 | advance $i || break | |
18 | done && | |
19 | git clone . test && | |
20 | ( | |
21 | cd test && | |
22 | git checkout -b b1 origin && | |
23 | git reset --hard HEAD^ && | |
24 | advance d && | |
25 | git checkout -b b2 origin && | |
26 | git reset --hard b1 && | |
27 | git checkout -b b3 origin && | |
28 | git reset --hard HEAD^ && | |
29 | git checkout -b b4 origin && | |
30 | advance e && | |
31 | advance f | |
57dac0bf MG |
32 | ) && |
33 | git checkout -b follower --track master && | |
34 | advance g | |
c0234b2e JH |
35 | ' |
36 | ||
37 | script='s/^..\(b.\)[ 0-9a-f]*\[\([^]]*\)\].*/\1 \2/p' | |
38 | cat >expect <<\EOF | |
39 | b1 ahead 1, behind 1 | |
40 | b2 ahead 1, behind 1 | |
41 | b3 behind 1 | |
42 | b4 ahead 2 | |
43 | EOF | |
44 | ||
45 | test_expect_success 'branch -v' ' | |
46 | ( | |
47 | cd test && | |
48 | git branch -v | |
49 | ) | | |
50 | sed -n -e "$script" >actual && | |
51 | test_cmp expect actual | |
52 | ' | |
53 | ||
54 | test_expect_success 'checkout' ' | |
55 | ( | |
56 | cd test && git checkout b1 | |
57 | ) >actual && | |
87539416 | 58 | grep "have 1 and 1 different" actual |
c0234b2e JH |
59 | ' |
60 | ||
5e6e2b48 | 61 | test_expect_success 'checkout with local tracked branch' ' |
57dac0bf | 62 | git checkout master && |
a48fcd83 | 63 | git checkout follower >actual && |
57dac0bf MG |
64 | grep "is ahead of" actual |
65 | ' | |
66 | ||
c0234b2e JH |
67 | test_expect_success 'status' ' |
68 | ( | |
69 | cd test && | |
70 | git checkout b1 >/dev/null && | |
71 | # reports nothing to commit | |
9e4b7ab6 | 72 | test_must_fail git commit --dry-run |
c0234b2e | 73 | ) >actual && |
87539416 | 74 | grep "have 1 and 1 different" actual |
c0234b2e JH |
75 | ' |
76 | ||
1be570f4 MG |
77 | test_expect_success 'status when tracking lightweight tags' ' |
78 | git checkout master && | |
79 | git tag light && | |
80 | git branch --track lighttrack light >actual && | |
81 | grep "set up to track" actual && | |
82 | git checkout lighttrack | |
83 | ' | |
c0234b2e | 84 | |
57ffc5f8 | 85 | test_expect_success 'status when tracking annotated tags' ' |
1be570f4 MG |
86 | git checkout master && |
87 | git tag -m heavy heavy && | |
88 | git branch --track heavytrack heavy >actual && | |
89 | grep "set up to track" actual && | |
90 | git checkout heavytrack | |
91 | ' | |
4fc50066 IL |
92 | |
93 | test_expect_success 'setup tracking with branch --set-upstream on existing branch' ' | |
94 | git branch from-master master && | |
95 | test_must_fail git config branch.from-master.merge > actual && | |
96 | git branch --set-upstream from-master master && | |
97 | git config branch.from-master.merge > actual && | |
98 | grep -q "^refs/heads/master$" actual | |
99 | ' | |
100 | ||
101 | test_expect_success '--set-upstream does not change branch' ' | |
102 | git branch from-master2 master && | |
103 | test_must_fail git config branch.from-master2.merge > actual && | |
104 | git rev-list from-master2 && | |
105 | git update-ref refs/heads/from-master2 from-master2^ && | |
106 | git rev-parse from-master2 >expect2 && | |
107 | git branch --set-upstream from-master2 master && | |
108 | git config branch.from-master.merge > actual && | |
109 | git rev-parse from-master2 >actual2 && | |
110 | grep -q "^refs/heads/master$" actual && | |
111 | cmp expect2 actual2 | |
112 | ' | |
c0234b2e | 113 | test_done |