t / t6040-tracking-info.shon commit Quote ' as \(aq in manpages (204d363)
   1#!/bin/sh
   2
   3test_description='remote tracking stats'
   4
   5. ./test-lib.sh
   6
   7advance () {
   8        echo "$1" >"$1" &&
   9        git add "$1" &&
  10        test_tick &&
  11        git commit -m "$1"
  12}
  13
  14test_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
  32        ) &&
  33        git checkout -b follower --track master &&
  34        advance g
  35'
  36
  37script='s/^..\(b.\)[     0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
  38cat >expect <<\EOF
  39b1 ahead 1, behind 1
  40b2 ahead 1, behind 1
  41b3 behind 1
  42b4 ahead 2
  43EOF
  44
  45test_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
  54test_expect_success 'checkout' '
  55        (
  56                cd test && git checkout b1
  57        ) >actual &&
  58        grep "have 1 and 1 different" actual
  59'
  60
  61test_expect_success 'checkout with local tracked branch' '
  62        git checkout master &&
  63        git checkout follower >actual
  64        grep "is ahead of" actual
  65'
  66
  67test_expect_success 'status' '
  68        (
  69                cd test &&
  70                git checkout b1 >/dev/null &&
  71                # reports nothing to commit
  72                test_must_fail git status
  73        ) >actual &&
  74        grep "have 1 and 1 different" actual
  75'
  76
  77
  78test_done