Code

Catch invalid --depth option passed to clone or fetch
[git.git] / t / t6040-tracking-info.sh
index aac212e936331db9a596fda0c4a9c0382e123797..19de5b16eb530d428f66e5161a3ab48fce34049d 100755 (executable)
@@ -29,7 +29,9 @@ test_expect_success setup '
                git checkout -b b4 origin &&
                advance e &&
                advance f
-       )
+       ) &&
+       git checkout -b follower --track master &&
+       advance g
 '
 
 script='s/^..\(b.\)[    0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
@@ -46,14 +48,20 @@ test_expect_success 'branch -v' '
                git branch -v
        ) |
        sed -n -e "$script" >actual &&
-       test_cmp expect actual
+       test_i18ncmp expect actual
 '
 
 test_expect_success 'checkout' '
        (
                cd test && git checkout b1
        ) >actual &&
-       grep -e "have 1 and 1 different" actual
+       grep "have 1 and 1 different" actual
+'
+
+test_expect_success 'checkout with local tracked branch' '
+       git checkout master &&
+       git checkout follower >actual &&
+       grep "is ahead of" actual
 '
 
 test_expect_success 'status' '
@@ -61,10 +69,59 @@ test_expect_success 'status' '
                cd test &&
                git checkout b1 >/dev/null &&
                # reports nothing to commit
-               test_must_fail git status
+               test_must_fail git commit --dry-run
        ) >actual &&
-       grep -e "have 1 and 1 different" actual
+       grep "have 1 and 1 different" actual
+'
+
+test_expect_success 'fail to track lightweight tags' '
+       git checkout master &&
+       git tag light &&
+       test_must_fail git branch --track lighttrack light >actual &&
+       test_must_fail grep "set up to track" actual &&
+       test_must_fail git checkout lighttrack
+'
+
+test_expect_success 'fail to track annotated tags' '
+       git checkout master &&
+       git tag -m heavy heavy &&
+       test_must_fail git branch --track heavytrack heavy >actual &&
+       test_must_fail grep "set up to track" actual &&
+       test_must_fail git checkout heavytrack
 '
 
+test_expect_success 'setup tracking with branch --set-upstream on existing branch' '
+       git branch from-master master &&
+       test_must_fail git config branch.from-master.merge > actual &&
+       git branch --set-upstream from-master master &&
+       git config branch.from-master.merge > actual &&
+       grep -q "^refs/heads/master$" actual
+'
+
+test_expect_success '--set-upstream does not change branch' '
+       git branch from-master2 master &&
+       test_must_fail git config branch.from-master2.merge > actual &&
+       git rev-list from-master2 &&
+       git update-ref refs/heads/from-master2 from-master2^ &&
+       git rev-parse from-master2 >expect2 &&
+       git branch --set-upstream from-master2 master &&
+       git config branch.from-master.merge > actual &&
+       git rev-parse from-master2 >actual2 &&
+       grep -q "^refs/heads/master$" actual &&
+       cmp expect2 actual2
+'
+
+test_expect_success '--set-upstream @{-1}' '
+       git checkout from-master &&
+       git checkout from-master2 &&
+       git config branch.from-master2.merge > expect2 &&
+       git branch --set-upstream @{-1} follower &&
+       git config branch.from-master.merge > actual &&
+       git config branch.from-master2.merge > actual2 &&
+       git branch --set-upstream from-master follower &&
+       git config branch.from-master.merge > expect &&
+       test_cmp expect2 actual2 &&
+       test_cmp expect actual
+'
 
 test_done