t / t6019-rev-list-ancestry-path.shon commit revision.c: add BOTTOM flag for commits (7f34a46)
   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#  F...I                 == F G H I
  18#  --ancestry-path F...I == F H I
  19#
  20#  G..M -- G.t                 == [nothing - was dropped in "-s ours" merge L]
  21#  --ancestry-path G..M -- G.t == H J L
  22
  23. ./test-lib.sh
  24
  25test_merge () {
  26        test_tick &&
  27        git merge -s ours -m "$2" "$1" &&
  28        git tag "$2"
  29}
  30
  31test_expect_success setup '
  32        test_commit A &&
  33        test_commit B &&
  34        test_commit C &&
  35        test_commit D &&
  36        test_commit E &&
  37        test_commit F &&
  38        git reset --hard C &&
  39        test_commit G &&
  40        test_merge E H &&
  41        test_commit I &&
  42        test_merge F J &&
  43        git reset --hard A &&
  44        test_commit K &&
  45        test_merge J L &&
  46        test_commit M
  47'
  48
  49test_expect_success 'rev-list D..M' '
  50        for c in E F G H I J K L M; do echo $c; done >expect &&
  51        git rev-list --format=%s D..M |
  52        sed -e "/^commit /d" |
  53        sort >actual &&
  54        test_cmp expect actual
  55'
  56
  57test_expect_success 'rev-list --ancestry-path D..M' '
  58        for c in E F H I J L M; do echo $c; done >expect &&
  59        git rev-list --ancestry-path --format=%s D..M |
  60        sed -e "/^commit /d" |
  61        sort >actual &&
  62        test_cmp expect actual
  63'
  64
  65test_expect_success 'rev-list D..M -- M.t' '
  66        echo M >expect &&
  67        git rev-list --format=%s D..M -- M.t |
  68        sed -e "/^commit /d" >actual &&
  69        test_cmp expect actual
  70'
  71
  72test_expect_success 'rev-list --ancestry-path D..M -- M.t' '
  73        echo M >expect &&
  74        git rev-list --ancestry-path --format=%s D..M -- M.t |
  75        sed -e "/^commit /d" >actual &&
  76        test_cmp expect actual
  77'
  78
  79test_expect_success 'rev-list F...I' '
  80        for c in F G H I; do echo $c; done >expect &&
  81        git rev-list --format=%s F...I |
  82        sed -e "/^commit /d" |
  83        sort >actual &&
  84        test_cmp expect actual
  85'
  86
  87test_expect_success 'rev-list --ancestry-path F...I' '
  88        for c in F H I; do echo $c; done >expect &&
  89        git rev-list --ancestry-path --format=%s F...I |
  90        sed -e "/^commit /d" |
  91        sort >actual &&
  92        test_cmp expect actual
  93'
  94
  95# G.t is dropped in an "-s ours" merge
  96test_expect_success 'rev-list G..M -- G.t' '
  97        >expect &&
  98        git rev-list --format=%s G..M -- G.t |
  99        sed -e "/^commit /d" >actual &&
 100        test_cmp expect actual
 101'
 102
 103test_expect_success 'rev-list --ancestry-path G..M -- G.t' '
 104        for c in H J L; do echo $c; done >expect &&
 105        git rev-list --ancestry-path --format=%s G..M -- G.t |
 106        sed -e "/^commit /d" |
 107        sort >actual &&
 108        test_cmp expect actual
 109'
 110
 111#   b---bc
 112#  / \ /
 113# a   X
 114#  \ / \
 115#   c---cb
 116#
 117# All refnames prefixed with 'x' to avoid confusion with the tags
 118# generated by test_commit on case-insensitive systems.
 119test_expect_success 'setup criss-cross' '
 120        mkdir criss-cross &&
 121        (cd criss-cross &&
 122         git init &&
 123         test_commit A &&
 124         git checkout -b xb master &&
 125         test_commit B &&
 126         git checkout -b xc master &&
 127         test_commit C &&
 128         git checkout -b xbc xb -- &&
 129         git merge xc &&
 130         git checkout -b xcb xc -- &&
 131         git merge xb &&
 132         git checkout master)
 133'
 134
 135# no commits in bc descend from cb
 136test_expect_success 'criss-cross: rev-list --ancestry-path cb..bc' '
 137        (cd criss-cross &&
 138         git rev-list --ancestry-path xcb..xbc > actual &&
 139         test -z "$(cat actual)")
 140'
 141
 142# no commits in repository descend from cb
 143test_expect_success 'criss-cross: rev-list --ancestry-path --all ^cb' '
 144        (cd criss-cross &&
 145         git rev-list --ancestry-path --all ^xcb > actual &&
 146         test -z "$(cat actual)")
 147'
 148
 149test_done