t / t6007-rev-list-cherry-pick-file.shon commit Merge branch 'tc/checkout-B' (07cd900)
   1#!/bin/sh
   2
   3test_description='test git rev-list --cherry-pick -- file'
   4
   5. ./test-lib.sh
   6
   7# A---B
   8#  \
   9#   \
  10#    C
  11#
  12# B changes a file foo.c, adding a line of text.  C changes foo.c as
  13# well as bar.c, but the change in foo.c was identical to change B.
  14
  15test_expect_success setup '
  16        echo Hallo > foo &&
  17        git add foo &&
  18        test_tick &&
  19        git commit -m "A" &&
  20        git tag A &&
  21        git checkout -b branch &&
  22        echo Bello > foo &&
  23        echo Cello > bar &&
  24        git add foo bar &&
  25        test_tick &&
  26        git commit -m "C" &&
  27        git tag C &&
  28        git checkout master &&
  29        git checkout branch foo &&
  30        test_tick &&
  31        git commit -m "B" &&
  32        git tag B
  33'
  34
  35cat >expect <<EOF
  36<tags/B
  37>tags/C
  38EOF
  39
  40test_expect_success '--left-right' '
  41        git rev-list --left-right B...C > actual &&
  42        git name-rev --stdin --name-only --refs="*tags/*" \
  43                < actual > actual.named &&
  44        test_cmp actual.named expect
  45'
  46
  47test_expect_success '--count' '
  48        git rev-list --count B...C > actual &&
  49        test "$(cat actual)" = 2
  50'
  51
  52test_expect_success '--cherry-pick foo comes up empty' '
  53        test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)"
  54'
  55
  56test_expect_success '--cherry-pick bar does not come up empty' '
  57        ! test -z "$(git rev-list --left-right --cherry-pick B...C -- bar)"
  58'
  59
  60test_expect_success '--cherry-pick with independent, but identical branches' '
  61        git symbolic-ref HEAD refs/heads/independent &&
  62        rm .git/index &&
  63        echo Hallo > foo &&
  64        git add foo &&
  65        test_tick &&
  66        git commit -m "independent" &&
  67        echo Bello > foo &&
  68        test_tick &&
  69        git commit -m "independent, too" foo &&
  70        test -z "$(git rev-list --left-right --cherry-pick \
  71                HEAD...master -- foo)"
  72'
  73
  74cat >expect <<EOF
  751       2
  76EOF
  77
  78# Insert an extra commit to break the symmetry
  79test_expect_success '--count --left-right' '
  80        git checkout branch &&
  81        test_commit D &&
  82        git rev-list --count --left-right B...D > actual &&
  83        test_cmp expect actual
  84'
  85
  86test_done