t / t6012-rev-list-simplify.shon commit Merge branch 'uk/rev-parse-parse-opt' (5cacf3d)
   1#!/bin/sh
   2
   3test_description='merge simplification'
   4
   5. ./test-lib.sh
   6
   7note () {
   8        git tag "$1"
   9}
  10
  11_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
  12_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
  13
  14unnote () {
  15        git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\)) |\1 |g"
  16}
  17
  18test_expect_success setup '
  19        echo "Hi there" >file &&
  20        git add file &&
  21        test_tick && git commit -m "Initial file" &&
  22        note A &&
  23
  24        git branch other-branch &&
  25
  26        echo "Hello" >file &&
  27        git add file &&
  28        test_tick && git commit -m "Modified file" &&
  29        note B &&
  30
  31        git checkout other-branch &&
  32
  33        echo "Hello" >file &&
  34        git add file &&
  35        test_tick && git commit -m "Modified the file identically" &&
  36        note C &&
  37
  38        echo "This is a stupid example" >another-file &&
  39        git add another-file &&
  40        test_tick && git commit -m "Add another file" &&
  41        note D &&
  42
  43        test_tick && git merge -m "merge" master &&
  44        note E &&
  45
  46        echo "Yet another" >elif &&
  47        git add elif &&
  48        test_tick && git commit -m "Irrelevant change" &&
  49        note F &&
  50
  51        git checkout master &&
  52        echo "Yet another" >elif &&
  53        git add elif &&
  54        test_tick && git commit -m "Another irrelevant change" &&
  55        note G &&
  56
  57        test_tick && git merge -m "merge" other-branch &&
  58        note H &&
  59
  60        echo "Final change" >file &&
  61        test_tick && git commit -a -m "Final change" &&
  62        note I
  63'
  64
  65FMT='tformat:%P         %H | %s'
  66
  67check_result () {
  68        for c in $1
  69        do
  70                echo "$c"
  71        done >expect &&
  72        shift &&
  73        param="$*" &&
  74        test_expect_success "log $param" '
  75                git log --pretty="$FMT" --parents $param |
  76                unnote >actual &&
  77                sed -e "s/^.*   \([^ ]*\) .*/\1/" >check <actual &&
  78                test_cmp expect check || {
  79                        cat actual
  80                        false
  81                }
  82        '
  83}
  84
  85check_result 'I H G F E D C B A' --full-history
  86check_result 'I H E C B A' --full-history -- file
  87check_result 'I H E C B A' --full-history --topo-order -- file
  88check_result 'I H E C B A' --full-history --date-order -- file
  89check_result 'I E C B A' --simplify-merges -- file
  90check_result 'I B A' -- file
  91check_result 'I B A' --topo-order -- file
  92
  93test_done