t / t6016-rev-list-graph-simplify-history.shon commit format-patch: respect --stat in cover letter's diffstat (284aeb7)
   1#!/bin/sh
   2
   3# There's more than one "correct" way to represent the history graphically.
   4# These tests depend on the current behavior of the graphing code.  If the
   5# graphing code is ever changed to draw the output differently, these tests
   6# cases will need to be updated to know about the new layout.
   7
   8test_description='--graph and simplified history'
   9
  10. ./test-lib.sh
  11
  12test_expect_success 'set up rev-list --graph test' '
  13        # 3 commits on branch A
  14        test_commit A1 foo.txt &&
  15        test_commit A2 bar.txt &&
  16        test_commit A3 bar.txt &&
  17        git branch -m master A &&
  18
  19        # 2 commits on branch B, started from A1
  20        git checkout -b B A1 &&
  21        test_commit B1 foo.txt &&
  22        test_commit B2 abc.txt &&
  23
  24        # 2 commits on branch C, started from A2
  25        git checkout -b C A2 &&
  26        test_commit C1 xyz.txt &&
  27        test_commit C2 xyz.txt &&
  28
  29        # Octopus merge B and C into branch A
  30        git checkout A &&
  31        git merge B C &&
  32        git tag A4 &&
  33
  34        test_commit A5 bar.txt &&
  35
  36        # More commits on C, then merge C into A
  37        git checkout C &&
  38        test_commit C3 foo.txt &&
  39        test_commit C4 bar.txt &&
  40        git checkout A &&
  41        git merge -s ours C &&
  42        git tag A6 &&
  43
  44        test_commit A7 bar.txt &&
  45
  46        # Store commit names in variables for later use
  47        A1=$(git rev-parse --verify A1) &&
  48        A2=$(git rev-parse --verify A2) &&
  49        A3=$(git rev-parse --verify A3) &&
  50        A4=$(git rev-parse --verify A4) &&
  51        A5=$(git rev-parse --verify A5) &&
  52        A6=$(git rev-parse --verify A6) &&
  53        A7=$(git rev-parse --verify A7) &&
  54        B1=$(git rev-parse --verify B1) &&
  55        B2=$(git rev-parse --verify B2) &&
  56        C1=$(git rev-parse --verify C1) &&
  57        C2=$(git rev-parse --verify C2) &&
  58        C3=$(git rev-parse --verify C3) &&
  59        C4=$(git rev-parse --verify C4)
  60        '
  61
  62test_expect_success '--graph --all' '
  63        rm -f expected &&
  64        echo "* $A7" >> expected &&
  65        echo "*   $A6" >> expected &&
  66        echo "|\\  " >> expected &&
  67        echo "| * $C4" >> expected &&
  68        echo "| * $C3" >> expected &&
  69        echo "* | $A5" >> expected &&
  70        echo "| |     " >> expected &&
  71        echo "|  \\    " >> expected &&
  72        echo "*-. \\   $A4" >> expected &&
  73        echo "|\\ \\ \\  " >> expected &&
  74        echo "| | |/  " >> expected &&
  75        echo "| | * $C2" >> expected &&
  76        echo "| | * $C1" >> expected &&
  77        echo "| * | $B2" >> expected &&
  78        echo "| * | $B1" >> expected &&
  79        echo "* | | $A3" >> expected &&
  80        echo "| |/  " >> expected &&
  81        echo "|/|   " >> expected &&
  82        echo "* | $A2" >> expected &&
  83        echo "|/  " >> expected &&
  84        echo "* $A1" >> expected &&
  85        git rev-list --graph --all > actual &&
  86        test_cmp expected actual
  87        '
  88
  89# Make sure the graph_is_interesting() code still realizes
  90# that undecorated merges are interesting, even with --simplify-by-decoration
  91test_expect_success '--graph --simplify-by-decoration' '
  92        rm -f expected &&
  93        git tag -d A4 &&
  94        echo "* $A7" >> expected &&
  95        echo "*   $A6" >> expected &&
  96        echo "|\\  " >> expected &&
  97        echo "| * $C4" >> expected &&
  98        echo "| * $C3" >> expected &&
  99        echo "* | $A5" >> expected &&
 100        echo "| |     " >> expected &&
 101        echo "|  \\    " >> expected &&
 102        echo "*-. \\   $A4" >> expected &&
 103        echo "|\\ \\ \\  " >> expected &&
 104        echo "| | |/  " >> expected &&
 105        echo "| | * $C2" >> expected &&
 106        echo "| | * $C1" >> expected &&
 107        echo "| * | $B2" >> expected &&
 108        echo "| * | $B1" >> expected &&
 109        echo "* | | $A3" >> expected &&
 110        echo "| |/  " >> expected &&
 111        echo "|/|   " >> expected &&
 112        echo "* | $A2" >> expected &&
 113        echo "|/  " >> expected &&
 114        echo "* $A1" >> expected &&
 115        git rev-list --graph --all --simplify-by-decoration > actual &&
 116        test_cmp expected actual
 117        '
 118
 119test_expect_success 'setup: get rid of decorations on B' '
 120        git tag -d B2 &&
 121        git tag -d B1 &&
 122        git branch -d B
 123'
 124
 125# Graph with branch B simplified away
 126test_expect_success '--graph --simplify-by-decoration prune branch B' '
 127        rm -f expected &&
 128        echo "* $A7" >> expected &&
 129        echo "*   $A6" >> expected &&
 130        echo "|\\  " >> expected &&
 131        echo "| * $C4" >> expected &&
 132        echo "| * $C3" >> expected &&
 133        echo "* | $A5" >> expected &&
 134        echo "* |   $A4" >> expected &&
 135        echo "|\\ \\  " >> expected &&
 136        echo "| |/  " >> expected &&
 137        echo "| * $C2" >> expected &&
 138        echo "| * $C1" >> expected &&
 139        echo "* | $A3" >> expected &&
 140        echo "|/  " >> expected &&
 141        echo "* $A2" >> expected &&
 142        echo "* $A1" >> expected &&
 143        git rev-list --graph --simplify-by-decoration --all > actual &&
 144        test_cmp expected actual
 145        '
 146
 147test_expect_success '--graph --full-history -- bar.txt' '
 148        rm -f expected &&
 149        echo "* $A7" >> expected &&
 150        echo "*   $A6" >> expected &&
 151        echo "|\\  " >> expected &&
 152        echo "| * $C4" >> expected &&
 153        echo "* | $A5" >> expected &&
 154        echo "* |   $A4" >> expected &&
 155        echo "|\\ \\  " >> expected &&
 156        echo "| |/  " >> expected &&
 157        echo "* | $A3" >> expected &&
 158        echo "|/  " >> expected &&
 159        echo "* $A2" >> expected &&
 160        git rev-list --graph --full-history --all -- bar.txt > actual &&
 161        test_cmp expected actual
 162        '
 163
 164test_expect_success '--graph --full-history --simplify-merges -- bar.txt' '
 165        rm -f expected &&
 166        echo "* $A7" >> expected &&
 167        echo "*   $A6" >> expected &&
 168        echo "|\\  " >> expected &&
 169        echo "| * $C4" >> expected &&
 170        echo "* | $A5" >> expected &&
 171        echo "* | $A3" >> expected &&
 172        echo "|/  " >> expected &&
 173        echo "* $A2" >> expected &&
 174        git rev-list --graph --full-history --simplify-merges --all \
 175                -- bar.txt > actual &&
 176        test_cmp expected actual
 177        '
 178
 179test_expect_success '--graph -- bar.txt' '
 180        rm -f expected &&
 181        echo "* $A7" >> expected &&
 182        echo "* $A5" >> expected &&
 183        echo "* $A3" >> expected &&
 184        echo "| * $C4" >> expected &&
 185        echo "|/  " >> expected &&
 186        echo "* $A2" >> expected &&
 187        git rev-list --graph --all -- bar.txt > actual &&
 188        test_cmp expected actual
 189        '
 190
 191test_expect_success '--graph --sparse -- bar.txt' '
 192        rm -f expected &&
 193        echo "* $A7" >> expected &&
 194        echo "* $A6" >> expected &&
 195        echo "* $A5" >> expected &&
 196        echo "* $A4" >> expected &&
 197        echo "* $A3" >> expected &&
 198        echo "| * $C4" >> expected &&
 199        echo "| * $C3" >> expected &&
 200        echo "| * $C2" >> expected &&
 201        echo "| * $C1" >> expected &&
 202        echo "|/  " >> expected &&
 203        echo "* $A2" >> expected &&
 204        echo "* $A1" >> expected &&
 205        git rev-list --graph --sparse --all -- bar.txt > actual &&
 206        test_cmp expected actual
 207        '
 208
 209test_expect_success '--graph ^C4' '
 210        rm -f expected &&
 211        echo "* $A7" >> expected &&
 212        echo "* $A6" >> expected &&
 213        echo "* $A5" >> expected &&
 214        echo "*   $A4" >> expected &&
 215        echo "|\\  " >> expected &&
 216        echo "| * $B2" >> expected &&
 217        echo "| * $B1" >> expected &&
 218        echo "* $A3" >> expected &&
 219        git rev-list --graph --all ^C4 > actual &&
 220        test_cmp expected actual
 221        '
 222
 223test_expect_success '--graph ^C3' '
 224        rm -f expected &&
 225        echo "* $A7" >> expected &&
 226        echo "*   $A6" >> expected &&
 227        echo "|\\  " >> expected &&
 228        echo "| * $C4" >> expected &&
 229        echo "* $A5" >> expected &&
 230        echo "*   $A4" >> expected &&
 231        echo "|\\  " >> expected &&
 232        echo "| * $B2" >> expected &&
 233        echo "| * $B1" >> expected &&
 234        echo "* $A3" >> expected &&
 235        git rev-list --graph --all ^C3 > actual &&
 236        test_cmp expected actual
 237        '
 238
 239# I don't think the ordering of the boundary commits is really
 240# that important, but this test depends on it.  If the ordering ever changes
 241# in the code, we'll need to update this test.
 242test_expect_success '--graph --boundary ^C3' '
 243        rm -f expected &&
 244        echo "* $A7" >> expected &&
 245        echo "*   $A6" >> expected &&
 246        echo "|\\  " >> expected &&
 247        echo "| * $C4" >> expected &&
 248        echo "* | $A5" >> expected &&
 249        echo "| |     " >> expected &&
 250        echo "|  \\    " >> expected &&
 251        echo "*-. \\   $A4" >> expected &&
 252        echo "|\\ \\ \\  " >> expected &&
 253        echo "| * | | $B2" >> expected &&
 254        echo "| * | | $B1" >> expected &&
 255        echo "* | | | $A3" >> expected &&
 256        echo "o | | | $A2" >> expected &&
 257        echo "|/ / /  " >> expected &&
 258        echo "o | | $A1" >> expected &&
 259        echo " / /  " >> expected &&
 260        echo "| o $C3" >> expected &&
 261        echo "|/  " >> expected &&
 262        echo "o $C2" >> expected &&
 263        git rev-list --graph --boundary --all ^C3 > actual &&
 264        test_cmp expected actual
 265        '
 266
 267test_done