1#!/bin/sh23test_description='merge simplification'45. ./test-lib.sh67note () {8git tag "$1"9}1011unnote () {12git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\)) |\1 |g"13}1415test_expect_success setup '16echo "Hi there" >file &&17git add file &&18test_tick && git commit -m "Initial file" &&19note A &&2021git branch other-branch &&2223echo "Hello" >file &&24git add file &&25test_tick && git commit -m "Modified file" &&26note B &&2728git checkout other-branch &&2930echo "Hello" >file &&31git add file &&32test_tick && git commit -m "Modified the file identically" &&33note C &&3435echo "This is a stupid example" >another-file &&36git add another-file &&37test_tick && git commit -m "Add another file" &&38note D &&3940test_tick && git merge -m "merge" master &&41note E &&4243echo "Yet another" >elif &&44git add elif &&45test_tick && git commit -m "Irrelevant change" &&46note F &&4748git checkout master &&49echo "Yet another" >elif &&50git add elif &&51test_tick && git commit -m "Another irrelevant change" &&52note G &&5354test_tick && git merge -m "merge" other-branch &&55note H &&5657echo "Final change" >file &&58test_tick && git commit -a -m "Final change" &&59note I &&6061git symbolic-ref HEAD refs/heads/unrelated &&62git rm -f "*" &&63echo "Unrelated branch" >side &&64git add side &&65test_tick && git commit -m "Side root" &&66note J &&6768git checkout master &&69test_tick && git merge -m "Coolest" unrelated &&70note K &&7172echo "Immaterial" >elif &&73git add elif &&74test_tick && git commit -m "Last" &&75note L76'7778FMT='tformat:%P %H | %s'7980check_result () {81for c in $182do83echo "$c"84done >expect &&85shift &&86param="$*" &&87test_expect_success "log $param" '88git log --pretty="$FMT" --parents $param |89unnote >actual &&90sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual &&91test_cmp expect check || {92cat actual93false94}95'96}9798check_result 'L K J I H G F E D C B A' --full-history99check_result 'K I H E C B A' --full-history -- file100check_result 'K I H E C B A' --full-history --topo-order -- file101check_result 'K I H E C B A' --full-history --date-order -- file102check_result 'I E C B A' --simplify-merges -- file103check_result 'I B A' -- file104check_result 'I B A' --topo-order -- file105check_result 'H' --first-parent -- another-file106107test_done