3 test_description
='remote tracking stats'
14 test_expect_success setup
'
22 git checkout -b b1 origin &&
23 git reset --hard HEAD^ &&
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 &&
33 git checkout -b follower --track master &&
37 script='s/^..\(b.\)[ 0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
45 test_expect_success
'branch -v' '
50 sed -n -e "$script" >actual &&
51 test_i18ncmp expect actual
55 b1 origin
/master
: ahead
1, behind
1
56 b2 origin
/master
: ahead
1, behind
1
57 b3 origin
/master
: behind
1
58 b4 origin
/master
: ahead
2
61 test_expect_success
'branch -vv' '
66 sed -n -e "$script" >actual &&
67 test_i18ncmp expect actual
70 test_expect_success
'checkout' '
72 cd test && git checkout b1
74 grep "have 1 and 1 different" actual
77 test_expect_success
'checkout with local tracked branch' '
78 git checkout master &&
79 git checkout follower >actual &&
80 grep "is ahead of" actual
83 test_expect_success
'status' '
86 git checkout b1 >/dev/null &&
87 # reports nothing to commit
88 test_must_fail git commit --dry-run
90 grep "have 1 and 1 different" actual
93 test_expect_success
'fail to track lightweight tags' '
94 git checkout master &&
96 test_must_fail git branch --track lighttrack light >actual &&
97 test_must_fail grep "set up to track" actual &&
98 test_must_fail git checkout lighttrack
101 test_expect_success
'fail to track annotated tags' '
102 git checkout master &&
103 git tag -m heavy heavy &&
104 test_must_fail git branch --track heavytrack heavy >actual &&
105 test_must_fail grep "set up to track" actual &&
106 test_must_fail git checkout heavytrack
109 test_expect_success
'setup tracking with branch --set-upstream on existing branch' '
110 git branch from-master master &&
111 test_must_fail git config branch.from-master.merge > actual &&
112 git branch --set-upstream from-master master &&
113 git config branch.from-master.merge > actual &&
114 grep -q "^refs/heads/master$" actual
117 test_expect_success
'--set-upstream does not change branch' '
118 git branch from-master2 master &&
119 test_must_fail git config branch.from-master2.merge > actual &&
120 git rev-list from-master2 &&
121 git update-ref refs/heads/from-master2 from-master2^ &&
122 git rev-parse from-master2 >expect2 &&
123 git branch --set-upstream from-master2 master &&
124 git config branch.from-master.merge > actual &&
125 git rev-parse from-master2 >actual2 &&
126 grep -q "^refs/heads/master$" actual &&