t / t6019-rev-list-ancestry-path.shon commit remote-hg: match hg merge behavior (6497a2b)
   1#!/bin/sh
   2
   3test_description='--ancestry-path'
   4
   5#          D---E-------F
   6#         /     \       \
   7#    B---C---G---H---I---J
   8#   /                     \
   9#  A-------K---------------L--M
  10#
  11#  D..M                 == E F G H I J K L M
  12#  --ancestry-path D..M == E F H I J L M
  13#
  14#  D..M -- M.t                 == M
  15#  --ancestry-path D..M -- M.t == M
  16
  17. ./test-lib.sh
  18
  19test_merge () {
  20        test_tick &&
  21        git merge -s ours -m "$2" "$1" &&
  22        git tag "$2"
  23}
  24
  25test_expect_success setup '
  26        test_commit A &&
  27        test_commit B &&
  28        test_commit C &&
  29        test_commit D &&
  30        test_commit E &&
  31        test_commit F &&
  32        git reset --hard C &&
  33        test_commit G &&
  34        test_merge E H &&
  35        test_commit I &&
  36        test_merge F J &&
  37        git reset --hard A &&
  38        test_commit K &&
  39        test_merge J L &&
  40        test_commit M
  41'
  42
  43test_expect_success 'rev-list D..M' '
  44        for c in E F G H I J K L M; do echo $c; done >expect &&
  45        git rev-list --format=%s D..M |
  46        sed -e "/^commit /d" |
  47        sort >actual &&
  48        test_cmp expect actual
  49'
  50
  51test_expect_success 'rev-list --ancestry-path D..M' '
  52        for c in E F H I J L M; do echo $c; done >expect &&
  53        git rev-list --ancestry-path --format=%s D..M |
  54        sed -e "/^commit /d" |
  55        sort >actual &&
  56        test_cmp expect actual
  57'
  58
  59test_expect_success 'rev-list D..M -- M.t' '
  60        echo M >expect &&
  61        git rev-list --format=%s D..M -- M.t |
  62        sed -e "/^commit /d" >actual &&
  63        test_cmp expect actual
  64'
  65
  66test_expect_success 'rev-list --ancestry-patch D..M -- M.t' '
  67        echo M >expect &&
  68        git rev-list --ancestry-path --format=%s D..M -- M.t |
  69        sed -e "/^commit /d" >actual &&
  70        test_cmp expect actual
  71'
  72
  73#   b---bc
  74#  / \ /
  75# a   X
  76#  \ / \
  77#   c---cb
  78#
  79# All refnames prefixed with 'x' to avoid confusion with the tags
  80# generated by test_commit on case-insensitive systems.
  81test_expect_success 'setup criss-cross' '
  82        mkdir criss-cross &&
  83        (cd criss-cross &&
  84         git init &&
  85         test_commit A &&
  86         git checkout -b xb master &&
  87         test_commit B &&
  88         git checkout -b xc master &&
  89         test_commit C &&
  90         git checkout -b xbc xb -- &&
  91         git merge xc &&
  92         git checkout -b xcb xc -- &&
  93         git merge xb &&
  94         git checkout master)
  95'
  96
  97# no commits in bc descend from cb
  98test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
  99        (cd criss-cross &&
 100         git rev-list --ancestry-path xcb..xbc > actual &&
 101         test -z "$(cat actual)")
 102'
 103
 104# no commits in repository descend from cb
 105test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
 106        (cd criss-cross &&
 107         git rev-list --ancestry-path --all ^xcb > actual &&
 108         test -z "$(cat actual)")
 109'
 110
 111test_done