t / t6007-rev-list-cherry-pick-file.shon commit Merge branch 'jc/name-branch' (fbdc056)
   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
  35test_expect_success '--cherry-pick foo comes up empty' '
  36        test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)"
  37'
  38
  39test_expect_success '--cherry-pick bar does not come up empty' '
  40        ! test -z "$(git rev-list --left-right --cherry-pick B...C -- bar)"
  41'
  42
  43test_expect_success '--cherry-pick with independent, but identical branches' '
  44        git symbolic-ref HEAD refs/heads/independent &&
  45        rm .git/index &&
  46        echo Hallo > foo &&
  47        git add foo &&
  48        test_tick &&
  49        git commit -m "independent" &&
  50        echo Bello > foo &&
  51        test_tick &&
  52        git commit -m "independent, too" foo &&
  53        test -z "$(git rev-list --left-right --cherry-pick \
  54                HEAD...master -- foo)"
  55'
  56
  57test_done