t / t6009-rev-list-parent.shon commit mingw: get pw_name in UTF-8 format (39a98e9)
   1#!/bin/sh
   2
   3test_description='ancestor culling and limiting by parent number'
   4
   5. ./test-lib.sh
   6
   7check_revlist () {
   8        rev_list_args="$1" &&
   9        shift &&
  10        git rev-parse "$@" >expect &&
  11        git rev-list $rev_list_args --all >actual &&
  12        test_cmp expect actual
  13}
  14
  15test_expect_success setup '
  16
  17        touch file &&
  18        git add file &&
  19
  20        test_commit one &&
  21
  22        test_tick=$(($test_tick - 2400)) &&
  23
  24        test_commit two &&
  25        test_commit three &&
  26        test_commit four &&
  27
  28        git log --pretty=oneline --abbrev-commit
  29'
  30
  31test_expect_success 'one is ancestor of others and should not be shown' '
  32
  33        git rev-list one --not four >result &&
  34        test_must_be_empty result
  35
  36'
  37
  38test_expect_success 'setup roots, merges and octopuses' '
  39
  40        git checkout --orphan newroot &&
  41        test_commit five &&
  42        git checkout -b sidebranch two &&
  43        test_commit six &&
  44        git checkout -b anotherbranch three &&
  45        test_commit seven &&
  46        git checkout -b yetanotherbranch four &&
  47        test_commit eight &&
  48        git checkout master &&
  49        test_tick &&
  50        git merge --allow-unrelated-histories -m normalmerge newroot &&
  51        git tag normalmerge &&
  52        test_tick &&
  53        git merge -m tripus sidebranch anotherbranch &&
  54        git tag tripus &&
  55        git checkout -b tetrabranch normalmerge &&
  56        test_tick &&
  57        git merge -m tetrapus sidebranch anotherbranch yetanotherbranch &&
  58        git tag tetrapus &&
  59        git checkout master
  60'
  61
  62test_expect_success 'rev-list roots' '
  63
  64        check_revlist "--max-parents=0" one five
  65'
  66
  67test_expect_success 'rev-list no merges' '
  68
  69        check_revlist "--max-parents=1" one eight seven six five four three two &&
  70        check_revlist "--no-merges" one eight seven six five four three two
  71'
  72
  73test_expect_success 'rev-list no octopuses' '
  74
  75        check_revlist "--max-parents=2" one normalmerge eight seven six five four three two
  76'
  77
  78test_expect_success 'rev-list no roots' '
  79
  80        check_revlist "--min-parents=1" tetrapus tripus normalmerge eight seven six four three two
  81'
  82
  83test_expect_success 'rev-list merges' '
  84
  85        check_revlist "--min-parents=2" tetrapus tripus normalmerge &&
  86        check_revlist "--merges" tetrapus tripus normalmerge
  87'
  88
  89test_expect_success 'rev-list octopus' '
  90
  91        check_revlist "--min-parents=3" tetrapus tripus
  92'
  93
  94test_expect_success 'rev-list ordinary commits' '
  95
  96        check_revlist "--min-parents=1 --max-parents=1" eight seven six four three two
  97'
  98
  99test_expect_success 'rev-list --merges --no-merges yields empty set' '
 100
 101        check_revlist "--min-parents=2 --no-merges" &&
 102        check_revlist "--merges --no-merges" &&
 103        check_revlist "--no-merges --merges"
 104'
 105
 106test_expect_success 'rev-list override and infinities' '
 107
 108        check_revlist "--min-parents=2 --max-parents=1 --max-parents=3" tripus normalmerge &&
 109        check_revlist "--min-parents=1 --min-parents=2 --max-parents=7" tetrapus tripus normalmerge &&
 110        check_revlist "--min-parents=2 --max-parents=8" tetrapus tripus normalmerge &&
 111        check_revlist "--min-parents=2 --max-parents=-1" tetrapus tripus normalmerge &&
 112        check_revlist "--min-parents=2 --no-max-parents" tetrapus tripus normalmerge &&
 113        check_revlist "--max-parents=0 --min-parents=1 --no-min-parents" one five
 114'
 115
 116test_expect_success 'dodecapus' '
 117
 118        roots= &&
 119        for i in 1 2 3 4 5 6 7 8 9 10 11
 120        do
 121                git checkout -b root$i five &&
 122                test_commit $i &&
 123                roots="$roots root$i" ||
 124                return
 125        done &&
 126        git checkout master &&
 127        test_tick &&
 128        git merge -m dodecapus $roots &&
 129        git tag dodecapus &&
 130
 131        check_revlist "--min-parents=4" dodecapus tetrapus &&
 132        check_revlist "--min-parents=8" dodecapus &&
 133        check_revlist "--min-parents=12" dodecapus &&
 134        check_revlist "--min-parents=13" &&
 135        check_revlist "--min-parents=4 --max-parents=11" tetrapus
 136'
 137
 138test_expect_success 'ancestors with the same commit time' '
 139
 140        test_tick_keep=$test_tick &&
 141        for i in 1 2 3 4 5 6 7 8; do
 142                test_tick=$test_tick_keep
 143                test_commit t$i
 144        done &&
 145        git rev-list t1^! --not t$i >result &&
 146        test_must_be_empty result
 147'
 148
 149test_done