t / t4202-log.shon commit grep: change non-ASCII -i test to stop using --debug (e01b4da)
   1#!/bin/sh
   2
   3test_description='git log'
   4
   5. ./test-lib.sh
   6. "$TEST_DIRECTORY/lib-gpg.sh"
   7. "$TEST_DIRECTORY/lib-terminal.sh"
   8
   9test_expect_success setup '
  10
  11        echo one >one &&
  12        git add one &&
  13        test_tick &&
  14        git commit -m initial &&
  15
  16        echo ichi >one &&
  17        git add one &&
  18        test_tick &&
  19        git commit -m second &&
  20
  21        git mv one ichi &&
  22        test_tick &&
  23        git commit -m third &&
  24
  25        cp ichi ein &&
  26        git add ein &&
  27        test_tick &&
  28        git commit -m fourth &&
  29
  30        mkdir a &&
  31        echo ni >a/two &&
  32        git add a/two &&
  33        test_tick &&
  34        git commit -m fifth  &&
  35
  36        git rm a/two &&
  37        test_tick &&
  38        git commit -m sixth
  39
  40'
  41
  42printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial" > expect
  43test_expect_success 'pretty' '
  44
  45        git log --pretty="format:%s" > actual &&
  46        test_cmp expect actual
  47'
  48
  49printf "sixth\nfifth\nfourth\nthird\nsecond\ninitial\n" > expect
  50test_expect_success 'pretty (tformat)' '
  51
  52        git log --pretty="tformat:%s" > actual &&
  53        test_cmp expect actual
  54'
  55
  56test_expect_success 'pretty (shortcut)' '
  57
  58        git log --pretty="%s" > actual &&
  59        test_cmp expect actual
  60'
  61
  62test_expect_success 'format' '
  63
  64        git log --format="%s" > actual &&
  65        test_cmp expect actual
  66'
  67
  68cat > expect << EOF
  69 This is
  70  the sixth
  71  commit.
  72 This is
  73  the fifth
  74  commit.
  75EOF
  76
  77test_expect_success 'format %w(11,1,2)' '
  78
  79        git log -2 --format="%w(11,1,2)This is the %s commit." > actual &&
  80        test_cmp expect actual
  81'
  82
  83test_expect_success 'format %w(,1,2)' '
  84
  85        git log -2 --format="%w(,1,2)This is%nthe %s%ncommit." > actual &&
  86        test_cmp expect actual
  87'
  88
  89cat > expect << EOF
  90804a787 sixth
  91394ef78 fifth
  925d31159 fourth
  932fbe8c0 third
  94f7dab8e second
  953a2fdcb initial
  96EOF
  97test_expect_success 'oneline' '
  98
  99        git log --oneline > actual &&
 100        test_cmp expect actual
 101'
 102
 103test_expect_success 'diff-filter=A' '
 104
 105        git log --no-renames --pretty="format:%s" --diff-filter=A HEAD > actual &&
 106        git log --no-renames --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
 107        printf "fifth\nfourth\nthird\ninitial" > expect &&
 108        test_cmp expect actual &&
 109        test_cmp expect actual-separate
 110
 111'
 112
 113test_expect_success 'diff-filter=M' '
 114
 115        actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
 116        expect=$(echo second) &&
 117        verbose test "$actual" = "$expect"
 118
 119'
 120
 121test_expect_success 'diff-filter=D' '
 122
 123        actual=$(git log --no-renames --pretty="format:%s" --diff-filter=D HEAD) &&
 124        expect=$(echo sixth ; echo third) &&
 125        verbose test "$actual" = "$expect"
 126
 127'
 128
 129test_expect_success 'diff-filter=R' '
 130
 131        actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
 132        expect=$(echo third) &&
 133        verbose test "$actual" = "$expect"
 134
 135'
 136
 137test_expect_success 'diff-filter=C' '
 138
 139        actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
 140        expect=$(echo fourth) &&
 141        verbose test "$actual" = "$expect"
 142
 143'
 144
 145test_expect_success 'git log --follow' '
 146
 147        actual=$(git log --follow --pretty="format:%s" ichi) &&
 148        expect=$(echo third ; echo second ; echo initial) &&
 149        verbose test "$actual" = "$expect"
 150'
 151
 152test_expect_success 'git config log.follow works like --follow' '
 153        test_config log.follow true &&
 154        actual=$(git log --pretty="format:%s" ichi) &&
 155        expect=$(echo third ; echo second ; echo initial) &&
 156        verbose test "$actual" = "$expect"
 157'
 158
 159test_expect_success 'git config log.follow does not die with multiple paths' '
 160        test_config log.follow true &&
 161        git log --pretty="format:%s" ichi ein
 162'
 163
 164test_expect_success 'git config log.follow does not die with no paths' '
 165        test_config log.follow true &&
 166        git log --
 167'
 168
 169test_expect_success 'git config log.follow is overridden by --no-follow' '
 170        test_config log.follow true &&
 171        actual=$(git log --no-follow --pretty="format:%s" ichi) &&
 172        expect="third" &&
 173        verbose test "$actual" = "$expect"
 174'
 175
 176cat > expect << EOF
 177804a787 sixth
 178394ef78 fifth
 1795d31159 fourth
 180EOF
 181test_expect_success 'git log --no-walk <commits> sorts by commit time' '
 182        git log --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
 183        test_cmp expect actual
 184'
 185
 186test_expect_success 'git log --no-walk=sorted <commits> sorts by commit time' '
 187        git log --no-walk=sorted --oneline 5d31159 804a787 394ef78 > actual &&
 188        test_cmp expect actual
 189'
 190
 191cat > expect << EOF
 192=== 804a787 sixth
 193=== 394ef78 fifth
 194=== 5d31159 fourth
 195EOF
 196test_expect_success 'git log --line-prefix="=== " --no-walk <commits> sorts by commit time' '
 197        git log --line-prefix="=== " --no-walk --oneline 5d31159 804a787 394ef78 > actual &&
 198        test_cmp expect actual
 199'
 200
 201cat > expect << EOF
 2025d31159 fourth
 203804a787 sixth
 204394ef78 fifth
 205EOF
 206test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
 207        git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
 208        test_cmp expect actual
 209'
 210
 211test_expect_success 'git show <commits> leaves list of commits as given' '
 212        git show --oneline -s 5d31159 804a787 394ef78 > actual &&
 213        test_cmp expect actual
 214'
 215
 216test_expect_success 'setup case sensitivity tests' '
 217        echo case >one &&
 218        test_tick &&
 219        git add one &&
 220        git commit -a -m Second
 221'
 222
 223test_expect_success 'log --grep' '
 224        echo second >expect &&
 225        git log -1 --pretty="tformat:%s" --grep=sec >actual &&
 226        test_cmp expect actual
 227'
 228
 229cat > expect << EOF
 230second
 231initial
 232EOF
 233test_expect_success 'log --invert-grep --grep' '
 234        # Fixed
 235        git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
 236        test_cmp expect actual &&
 237
 238        # POSIX basic
 239        git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
 240        test_cmp expect actual &&
 241
 242        # POSIX extended
 243        git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
 244        test_cmp expect actual &&
 245
 246        # PCRE
 247        if test_have_prereq PCRE
 248        then
 249                git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep --grep=t[h] --grep=S[e]c >actual &&
 250                test_cmp expect actual
 251        fi
 252'
 253
 254test_expect_success 'log --invert-grep --grep -i' '
 255        echo initial >expect &&
 256
 257        # Fixed
 258        git -c grep.patternType=fixed log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
 259        test_cmp expect actual &&
 260
 261        # POSIX basic
 262        git -c grep.patternType=basic log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
 263        test_cmp expect actual &&
 264
 265        # POSIX extended
 266        git -c grep.patternType=extended log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
 267        test_cmp expect actual &&
 268
 269        # PCRE
 270        if test_have_prereq PCRE
 271        then
 272                git -c grep.patternType=perl log --pretty="tformat:%s" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&
 273                test_cmp expect actual
 274        fi
 275'
 276
 277test_expect_success 'log --grep option parsing' '
 278        echo second >expect &&
 279        git log -1 --pretty="tformat:%s" --grep sec >actual &&
 280        test_cmp expect actual &&
 281        test_must_fail git log -1 --pretty="tformat:%s" --grep
 282'
 283
 284test_expect_success 'log -i --grep' '
 285        echo Second >expect &&
 286        git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
 287        test_cmp expect actual
 288'
 289
 290test_expect_success 'log --grep -i' '
 291        echo Second >expect &&
 292
 293        # Fixed
 294        git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
 295        test_cmp expect actual &&
 296
 297        # POSIX basic
 298        git -c grep.patternType=basic log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
 299        test_cmp expect actual &&
 300
 301        # POSIX extended
 302        git -c grep.patternType=extended log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
 303        test_cmp expect actual &&
 304
 305        # PCRE
 306        if test_have_prereq PCRE
 307        then
 308                git -c grep.patternType=perl log -1 --pretty="tformat:%s" --grep=s[e]c -i >actual &&
 309                test_cmp expect actual
 310        fi
 311'
 312
 313test_expect_success 'log -F -E --grep=<ere> uses ere' '
 314        echo second >expect &&
 315        # basic would need \(s\) to do the same
 316        git log -1 --pretty="tformat:%s" -F -E --grep="(s).c.nd" >actual &&
 317        test_cmp expect actual
 318'
 319
 320test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '
 321        test_when_finished "rm -rf num_commits" &&
 322        git init num_commits &&
 323        (
 324                cd num_commits &&
 325                test_commit 1d &&
 326                test_commit 2e
 327        ) &&
 328
 329        # In PCRE \d in [\d] is like saying "0-9", and matches the 2
 330        # in 2e...
 331        echo 2e >expect &&
 332        git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
 333        test_cmp expect actual &&
 334
 335        # ...in POSIX basic and extended it is the same as [d],
 336        # i.e. "d", which matches 1d, but does not match 2e.
 337        echo 1d >expect &&
 338        git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
 339        test_cmp expect actual
 340'
 341
 342test_expect_success 'log with grep.patternType configuration' '
 343        >expect &&
 344        git -c grep.patterntype=fixed \
 345        log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
 346        test_cmp expect actual
 347'
 348
 349test_expect_success 'log with grep.patternType configuration and command line' '
 350        echo second >expect &&
 351        git -c grep.patterntype=fixed \
 352        log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
 353        test_cmp expect actual
 354'
 355
 356test_expect_success 'log with various grep.patternType configurations & command-lines' '
 357        git init pattern-type &&
 358        (
 359                cd pattern-type &&
 360                test_commit 1 file A &&
 361
 362                # The tagname is overridden here because creating a
 363                # tag called "(1|2)" as test_commit would otherwise
 364                # implicitly do would fail on e.g. MINGW.
 365                test_commit "(1|2)" file B 2 &&
 366
 367                echo "(1|2)" >expect.fixed &&
 368                cp expect.fixed expect.basic &&
 369                cp expect.fixed expect.extended &&
 370                cp expect.fixed expect.perl &&
 371
 372                # A strcmp-like match with fixed.
 373                git -c grep.patternType=fixed log --pretty=tformat:%s \
 374                        --grep="(1|2)" >actual.fixed &&
 375
 376                # POSIX basic matches (, | and ) literally.
 377                git -c grep.patternType=basic log --pretty=tformat:%s \
 378                        --grep="(.|.)" >actual.basic &&
 379
 380                # POSIX extended needs to have | escaped to match it
 381                # literally, whereas under basic this is the same as
 382                # (|2), i.e. it would also match "1". This test checks
 383                # for extended by asserting that it is not matching
 384                # what basic would match.
 385                git -c grep.patternType=extended log --pretty=tformat:%s \
 386                        --grep="\|2" >actual.extended &&
 387                if test_have_prereq PCRE
 388                then
 389                        # Only PCRE would match [\d]\| with only
 390                        # "(1|2)" due to [\d]. POSIX basic would match
 391                        # both it and "1" since similarly to the
 392                        # extended match above it is the same as
 393                        # \([\d]\|\). POSIX extended would
 394                        # match neither.
 395                        git -c grep.patternType=perl log --pretty=tformat:%s \
 396                                --grep="[\d]\|" >actual.perl &&
 397                        test_cmp expect.perl actual.perl
 398                fi &&
 399                test_cmp expect.fixed actual.fixed &&
 400                test_cmp expect.basic actual.basic &&
 401                test_cmp expect.extended actual.extended &&
 402
 403                git log --pretty=tformat:%s -F \
 404                        --grep="(1|2)" >actual.fixed.short-arg &&
 405                git log --pretty=tformat:%s -E \
 406                        --grep="\|2" >actual.extended.short-arg &&
 407                test_cmp expect.fixed actual.fixed.short-arg &&
 408                test_cmp expect.extended actual.extended.short-arg &&
 409
 410                git log --pretty=tformat:%s --fixed-strings \
 411                        --grep="(1|2)" >actual.fixed.long-arg &&
 412                git log --pretty=tformat:%s --basic-regexp \
 413                        --grep="(.|.)" >actual.basic.long-arg &&
 414                git log --pretty=tformat:%s --extended-regexp \
 415                        --grep="\|2" >actual.extended.long-arg &&
 416                if test_have_prereq PCRE
 417                then
 418                        git log --pretty=tformat:%s --perl-regexp \
 419                                --grep="[\d]\|" >actual.perl.long-arg &&
 420                        test_cmp expect.perl actual.perl.long-arg
 421                else
 422                        test_must_fail git log --perl-regexp \
 423                                --grep="[\d]\|"
 424                fi &&
 425                test_cmp expect.fixed actual.fixed.long-arg &&
 426                test_cmp expect.basic actual.basic.long-arg &&
 427                test_cmp expect.extended actual.extended.long-arg
 428        )
 429'
 430
 431cat > expect <<EOF
 432* Second
 433* sixth
 434* fifth
 435* fourth
 436* third
 437* second
 438* initial
 439EOF
 440
 441test_expect_success 'simple log --graph' '
 442        git log --graph --pretty=tformat:%s >actual &&
 443        test_cmp expect actual
 444'
 445
 446cat > expect <<EOF
 447123 * Second
 448123 * sixth
 449123 * fifth
 450123 * fourth
 451123 * third
 452123 * second
 453123 * initial
 454EOF
 455
 456test_expect_success 'simple log --graph --line-prefix="123 "' '
 457        git log --graph --line-prefix="123 " --pretty=tformat:%s >actual &&
 458        test_cmp expect actual
 459'
 460
 461test_expect_success 'set up merge history' '
 462        git checkout -b side HEAD~4 &&
 463        test_commit side-1 1 1 &&
 464        test_commit side-2 2 2 &&
 465        git checkout master &&
 466        git merge side
 467'
 468
 469cat > expect <<\EOF
 470*   Merge branch 'side'
 471|\
 472| * side-2
 473| * side-1
 474* | Second
 475* | sixth
 476* | fifth
 477* | fourth
 478|/
 479* third
 480* second
 481* initial
 482EOF
 483
 484test_expect_success 'log --graph with merge' '
 485        git log --graph --date-order --pretty=tformat:%s |
 486                sed "s/ *\$//" >actual &&
 487        test_cmp expect actual
 488'
 489
 490cat > expect <<\EOF
 491| | | *   Merge branch 'side'
 492| | | |\
 493| | | | * side-2
 494| | | | * side-1
 495| | | * | Second
 496| | | * | sixth
 497| | | * | fifth
 498| | | * | fourth
 499| | | |/
 500| | | * third
 501| | | * second
 502| | | * initial
 503EOF
 504
 505test_expect_success 'log --graph --line-prefix="| | | " with merge' '
 506        git log --line-prefix="| | | " --graph --date-order --pretty=tformat:%s |
 507                sed "s/ *\$//" >actual &&
 508        test_cmp expect actual
 509'
 510
 511cat > expect.colors <<\EOF
 512*   Merge branch 'side'
 513<BLUE>|<RESET><CYAN>\<RESET>
 514<BLUE>|<RESET> * side-2
 515<BLUE>|<RESET> * side-1
 516* <CYAN>|<RESET> Second
 517* <CYAN>|<RESET> sixth
 518* <CYAN>|<RESET> fifth
 519* <CYAN>|<RESET> fourth
 520<CYAN>|<RESET><CYAN>/<RESET>
 521* third
 522* second
 523* initial
 524EOF
 525
 526test_expect_success 'log --graph with merge with log.graphColors' '
 527        test_config log.graphColors " blue,invalid-color, cyan, red  , " &&
 528        git log --color=always --graph --date-order --pretty=tformat:%s |
 529                test_decode_color | sed "s/ *\$//" >actual &&
 530        test_cmp expect.colors actual
 531'
 532
 533test_expect_success 'log --raw --graph -m with merge' '
 534        git log --raw --graph --oneline -m master | head -n 500 >actual &&
 535        grep "initial" actual
 536'
 537
 538test_expect_success 'diff-tree --graph' '
 539        git diff-tree --graph master^ | head -n 500 >actual &&
 540        grep "one" actual
 541'
 542
 543cat > expect <<\EOF
 544*   commit master
 545|\  Merge: A B
 546| | Author: A U Thor <author@example.com>
 547| |
 548| |     Merge branch 'side'
 549| |
 550| * commit side
 551| | Author: A U Thor <author@example.com>
 552| |
 553| |     side-2
 554| |
 555| * commit tags/side-1
 556| | Author: A U Thor <author@example.com>
 557| |
 558| |     side-1
 559| |
 560* | commit master~1
 561| | Author: A U Thor <author@example.com>
 562| |
 563| |     Second
 564| |
 565* | commit master~2
 566| | Author: A U Thor <author@example.com>
 567| |
 568| |     sixth
 569| |
 570* | commit master~3
 571| | Author: A U Thor <author@example.com>
 572| |
 573| |     fifth
 574| |
 575* | commit master~4
 576|/  Author: A U Thor <author@example.com>
 577|
 578|       fourth
 579|
 580* commit tags/side-1~1
 581| Author: A U Thor <author@example.com>
 582|
 583|     third
 584|
 585* commit tags/side-1~2
 586| Author: A U Thor <author@example.com>
 587|
 588|     second
 589|
 590* commit tags/side-1~3
 591  Author: A U Thor <author@example.com>
 592
 593      initial
 594EOF
 595
 596test_expect_success 'log --graph with full output' '
 597        git log --graph --date-order --pretty=short |
 598                git name-rev --name-only --stdin |
 599                sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
 600        test_cmp expect actual
 601'
 602
 603test_expect_success 'set up more tangled history' '
 604        git checkout -b tangle HEAD~6 &&
 605        test_commit tangle-a tangle-a a &&
 606        git merge master~3 &&
 607        git merge side~1 &&
 608        git checkout master &&
 609        git merge tangle &&
 610        git checkout -b reach &&
 611        test_commit reach &&
 612        git checkout master &&
 613        git checkout -b octopus-a &&
 614        test_commit octopus-a &&
 615        git checkout master &&
 616        git checkout -b octopus-b &&
 617        test_commit octopus-b &&
 618        git checkout master &&
 619        test_commit seventh &&
 620        git merge octopus-a octopus-b &&
 621        git merge reach
 622'
 623
 624cat > expect <<\EOF
 625*   Merge tag 'reach'
 626|\
 627| \
 628|  \
 629*-. \   Merge tags 'octopus-a' and 'octopus-b'
 630|\ \ \
 631* | | | seventh
 632| | * | octopus-b
 633| |/ /
 634|/| |
 635| * | octopus-a
 636|/ /
 637| * reach
 638|/
 639*   Merge branch 'tangle'
 640|\
 641| *   Merge branch 'side' (early part) into tangle
 642| |\
 643| * \   Merge branch 'master' (early part) into tangle
 644| |\ \
 645| * | | tangle-a
 646* | | |   Merge branch 'side'
 647|\ \ \ \
 648| * | | | side-2
 649| | |_|/
 650| |/| |
 651| * | | side-1
 652* | | | Second
 653* | | | sixth
 654| |_|/
 655|/| |
 656* | | fifth
 657* | | fourth
 658|/ /
 659* | third
 660|/
 661* second
 662* initial
 663EOF
 664
 665test_expect_success 'log --graph with merge' '
 666        git log --graph --date-order --pretty=tformat:%s |
 667                sed "s/ *\$//" >actual &&
 668        test_cmp expect actual
 669'
 670
 671test_expect_success 'log.decorate configuration' '
 672        git log --oneline --no-decorate >expect.none &&
 673        git log --oneline --decorate >expect.short &&
 674        git log --oneline --decorate=full >expect.full &&
 675
 676        echo "[log] decorate" >>.git/config &&
 677        git log --oneline >actual &&
 678        test_cmp expect.short actual &&
 679
 680        test_config log.decorate true &&
 681        git log --oneline >actual &&
 682        test_cmp expect.short actual &&
 683        git log --oneline --decorate=full >actual &&
 684        test_cmp expect.full actual &&
 685        git log --oneline --decorate=no >actual &&
 686        test_cmp expect.none actual &&
 687
 688        test_config log.decorate no &&
 689        git log --oneline >actual &&
 690        test_cmp expect.none actual &&
 691        git log --oneline --decorate >actual &&
 692        test_cmp expect.short actual &&
 693        git log --oneline --decorate=full >actual &&
 694        test_cmp expect.full actual &&
 695
 696        test_config log.decorate 1 &&
 697        git log --oneline >actual &&
 698        test_cmp expect.short actual &&
 699        git log --oneline --decorate=full >actual &&
 700        test_cmp expect.full actual &&
 701        git log --oneline --decorate=no >actual &&
 702        test_cmp expect.none actual &&
 703
 704        test_config log.decorate short &&
 705        git log --oneline >actual &&
 706        test_cmp expect.short actual &&
 707        git log --oneline --no-decorate >actual &&
 708        test_cmp expect.none actual &&
 709        git log --oneline --decorate=full >actual &&
 710        test_cmp expect.full actual &&
 711
 712        test_config log.decorate full &&
 713        git log --oneline >actual &&
 714        test_cmp expect.full actual &&
 715        git log --oneline --no-decorate >actual &&
 716        test_cmp expect.none actual &&
 717        git log --oneline --decorate >actual &&
 718        test_cmp expect.short actual &&
 719
 720        test_unconfig log.decorate &&
 721        git log --pretty=raw >expect.raw &&
 722        test_config log.decorate full &&
 723        git log --pretty=raw >actual &&
 724        test_cmp expect.raw actual
 725
 726'
 727
 728test_expect_success TTY 'log output on a TTY' '
 729        git log --oneline --decorate >expect.short &&
 730
 731        test_terminal git log --oneline >actual &&
 732        test_cmp expect.short actual
 733'
 734
 735test_expect_success 'reflog is expected format' '
 736        git log -g --abbrev-commit --pretty=oneline >expect &&
 737        git reflog >actual &&
 738        test_cmp expect actual
 739'
 740
 741test_expect_success 'whatchanged is expected format' '
 742        git log --no-merges --raw >expect &&
 743        git whatchanged >actual &&
 744        test_cmp expect actual
 745'
 746
 747test_expect_success 'log.abbrevCommit configuration' '
 748        git log --abbrev-commit >expect.log.abbrev &&
 749        git log --no-abbrev-commit >expect.log.full &&
 750        git log --pretty=raw >expect.log.raw &&
 751        git reflog --abbrev-commit >expect.reflog.abbrev &&
 752        git reflog --no-abbrev-commit >expect.reflog.full &&
 753        git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
 754        git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
 755
 756        test_config log.abbrevCommit true &&
 757
 758        git log >actual &&
 759        test_cmp expect.log.abbrev actual &&
 760        git log --no-abbrev-commit >actual &&
 761        test_cmp expect.log.full actual &&
 762
 763        git log --pretty=raw >actual &&
 764        test_cmp expect.log.raw actual &&
 765
 766        git reflog >actual &&
 767        test_cmp expect.reflog.abbrev actual &&
 768        git reflog --no-abbrev-commit >actual &&
 769        test_cmp expect.reflog.full actual &&
 770
 771        git whatchanged >actual &&
 772        test_cmp expect.whatchanged.abbrev actual &&
 773        git whatchanged --no-abbrev-commit >actual &&
 774        test_cmp expect.whatchanged.full actual
 775'
 776
 777test_expect_success 'show added path under "--follow -M"' '
 778        # This tests for a regression introduced in v1.7.2-rc0~103^2~2
 779        test_create_repo regression &&
 780        (
 781                cd regression &&
 782                test_commit needs-another-commit &&
 783                test_commit foo.bar &&
 784                git log -M --follow -p foo.bar.t &&
 785                git log -M --follow --stat foo.bar.t &&
 786                git log -M --follow --name-only foo.bar.t
 787        )
 788'
 789
 790test_expect_success 'git log -c --follow' '
 791        test_create_repo follow-c &&
 792        (
 793                cd follow-c &&
 794                test_commit initial file original &&
 795                git rm file &&
 796                test_commit rename file2 original &&
 797                git reset --hard initial &&
 798                test_commit modify file foo &&
 799                git merge -m merge rename &&
 800                git log -c --follow file2
 801        )
 802'
 803
 804cat >expect <<\EOF
 805*   commit COMMIT_OBJECT_NAME
 806|\  Merge: MERGE_PARENTS
 807| | Author: A U Thor <author@example.com>
 808| |
 809| |     Merge HEADS DESCRIPTION
 810| |
 811| * commit COMMIT_OBJECT_NAME
 812| | Author: A U Thor <author@example.com>
 813| |
 814| |     reach
 815| | ---
 816| |  reach.t | 1 +
 817| |  1 file changed, 1 insertion(+)
 818| |
 819| | diff --git a/reach.t b/reach.t
 820| | new file mode 100644
 821| | index 0000000..10c9591
 822| | --- /dev/null
 823| | +++ b/reach.t
 824| | @@ -0,0 +1 @@
 825| | +reach
 826| |
 827|  \
 828*-. \   commit COMMIT_OBJECT_NAME
 829|\ \ \  Merge: MERGE_PARENTS
 830| | | | Author: A U Thor <author@example.com>
 831| | | |
 832| | | |     Merge HEADS DESCRIPTION
 833| | | |
 834| | * | commit COMMIT_OBJECT_NAME
 835| | |/  Author: A U Thor <author@example.com>
 836| | |
 837| | |       octopus-b
 838| | |   ---
 839| | |    octopus-b.t | 1 +
 840| | |    1 file changed, 1 insertion(+)
 841| | |
 842| | |   diff --git a/octopus-b.t b/octopus-b.t
 843| | |   new file mode 100644
 844| | |   index 0000000..d5fcad0
 845| | |   --- /dev/null
 846| | |   +++ b/octopus-b.t
 847| | |   @@ -0,0 +1 @@
 848| | |   +octopus-b
 849| | |
 850| * | commit COMMIT_OBJECT_NAME
 851| |/  Author: A U Thor <author@example.com>
 852| |
 853| |       octopus-a
 854| |   ---
 855| |    octopus-a.t | 1 +
 856| |    1 file changed, 1 insertion(+)
 857| |
 858| |   diff --git a/octopus-a.t b/octopus-a.t
 859| |   new file mode 100644
 860| |   index 0000000..11ee015
 861| |   --- /dev/null
 862| |   +++ b/octopus-a.t
 863| |   @@ -0,0 +1 @@
 864| |   +octopus-a
 865| |
 866* | commit COMMIT_OBJECT_NAME
 867|/  Author: A U Thor <author@example.com>
 868|
 869|       seventh
 870|   ---
 871|    seventh.t | 1 +
 872|    1 file changed, 1 insertion(+)
 873|
 874|   diff --git a/seventh.t b/seventh.t
 875|   new file mode 100644
 876|   index 0000000..9744ffc
 877|   --- /dev/null
 878|   +++ b/seventh.t
 879|   @@ -0,0 +1 @@
 880|   +seventh
 881|
 882*   commit COMMIT_OBJECT_NAME
 883|\  Merge: MERGE_PARENTS
 884| | Author: A U Thor <author@example.com>
 885| |
 886| |     Merge branch 'tangle'
 887| |
 888| *   commit COMMIT_OBJECT_NAME
 889| |\  Merge: MERGE_PARENTS
 890| | | Author: A U Thor <author@example.com>
 891| | |
 892| | |     Merge branch 'side' (early part) into tangle
 893| | |
 894| * |   commit COMMIT_OBJECT_NAME
 895| |\ \  Merge: MERGE_PARENTS
 896| | | | Author: A U Thor <author@example.com>
 897| | | |
 898| | | |     Merge branch 'master' (early part) into tangle
 899| | | |
 900| * | | commit COMMIT_OBJECT_NAME
 901| | | | Author: A U Thor <author@example.com>
 902| | | |
 903| | | |     tangle-a
 904| | | | ---
 905| | | |  tangle-a | 1 +
 906| | | |  1 file changed, 1 insertion(+)
 907| | | |
 908| | | | diff --git a/tangle-a b/tangle-a
 909| | | | new file mode 100644
 910| | | | index 0000000..7898192
 911| | | | --- /dev/null
 912| | | | +++ b/tangle-a
 913| | | | @@ -0,0 +1 @@
 914| | | | +a
 915| | | |
 916* | | |   commit COMMIT_OBJECT_NAME
 917|\ \ \ \  Merge: MERGE_PARENTS
 918| | | | | Author: A U Thor <author@example.com>
 919| | | | |
 920| | | | |     Merge branch 'side'
 921| | | | |
 922| * | | | commit COMMIT_OBJECT_NAME
 923| | |_|/  Author: A U Thor <author@example.com>
 924| |/| |
 925| | | |       side-2
 926| | | |   ---
 927| | | |    2 | 1 +
 928| | | |    1 file changed, 1 insertion(+)
 929| | | |
 930| | | |   diff --git a/2 b/2
 931| | | |   new file mode 100644
 932| | | |   index 0000000..0cfbf08
 933| | | |   --- /dev/null
 934| | | |   +++ b/2
 935| | | |   @@ -0,0 +1 @@
 936| | | |   +2
 937| | | |
 938| * | | commit COMMIT_OBJECT_NAME
 939| | | | Author: A U Thor <author@example.com>
 940| | | |
 941| | | |     side-1
 942| | | | ---
 943| | | |  1 | 1 +
 944| | | |  1 file changed, 1 insertion(+)
 945| | | |
 946| | | | diff --git a/1 b/1
 947| | | | new file mode 100644
 948| | | | index 0000000..d00491f
 949| | | | --- /dev/null
 950| | | | +++ b/1
 951| | | | @@ -0,0 +1 @@
 952| | | | +1
 953| | | |
 954* | | | commit COMMIT_OBJECT_NAME
 955| | | | Author: A U Thor <author@example.com>
 956| | | |
 957| | | |     Second
 958| | | | ---
 959| | | |  one | 1 +
 960| | | |  1 file changed, 1 insertion(+)
 961| | | |
 962| | | | diff --git a/one b/one
 963| | | | new file mode 100644
 964| | | | index 0000000..9a33383
 965| | | | --- /dev/null
 966| | | | +++ b/one
 967| | | | @@ -0,0 +1 @@
 968| | | | +case
 969| | | |
 970* | | | commit COMMIT_OBJECT_NAME
 971| |_|/  Author: A U Thor <author@example.com>
 972|/| |
 973| | |       sixth
 974| | |   ---
 975| | |    a/two | 1 -
 976| | |    1 file changed, 1 deletion(-)
 977| | |
 978| | |   diff --git a/a/two b/a/two
 979| | |   deleted file mode 100644
 980| | |   index 9245af5..0000000
 981| | |   --- a/a/two
 982| | |   +++ /dev/null
 983| | |   @@ -1 +0,0 @@
 984| | |   -ni
 985| | |
 986* | | commit COMMIT_OBJECT_NAME
 987| | | Author: A U Thor <author@example.com>
 988| | |
 989| | |     fifth
 990| | | ---
 991| | |  a/two | 1 +
 992| | |  1 file changed, 1 insertion(+)
 993| | |
 994| | | diff --git a/a/two b/a/two
 995| | | new file mode 100644
 996| | | index 0000000..9245af5
 997| | | --- /dev/null
 998| | | +++ b/a/two
 999| | | @@ -0,0 +1 @@
1000| | | +ni
1001| | |
1002* | | commit COMMIT_OBJECT_NAME
1003|/ /  Author: A U Thor <author@example.com>
1004| |
1005| |       fourth
1006| |   ---
1007| |    ein | 1 +
1008| |    1 file changed, 1 insertion(+)
1009| |
1010| |   diff --git a/ein b/ein
1011| |   new file mode 100644
1012| |   index 0000000..9d7e69f
1013| |   --- /dev/null
1014| |   +++ b/ein
1015| |   @@ -0,0 +1 @@
1016| |   +ichi
1017| |
1018* | commit COMMIT_OBJECT_NAME
1019|/  Author: A U Thor <author@example.com>
1020|
1021|       third
1022|   ---
1023|    ichi | 1 +
1024|    one  | 1 -
1025|    2 files changed, 1 insertion(+), 1 deletion(-)
1026|
1027|   diff --git a/ichi b/ichi
1028|   new file mode 100644
1029|   index 0000000..9d7e69f
1030|   --- /dev/null
1031|   +++ b/ichi
1032|   @@ -0,0 +1 @@
1033|   +ichi
1034|   diff --git a/one b/one
1035|   deleted file mode 100644
1036|   index 9d7e69f..0000000
1037|   --- a/one
1038|   +++ /dev/null
1039|   @@ -1 +0,0 @@
1040|   -ichi
1041|
1042* commit COMMIT_OBJECT_NAME
1043| Author: A U Thor <author@example.com>
1044|
1045|     second
1046| ---
1047|  one | 2 +-
1048|  1 file changed, 1 insertion(+), 1 deletion(-)
1049|
1050| diff --git a/one b/one
1051| index 5626abf..9d7e69f 100644
1052| --- a/one
1053| +++ b/one
1054| @@ -1 +1 @@
1055| -one
1056| +ichi
1057|
1058* commit COMMIT_OBJECT_NAME
1059  Author: A U Thor <author@example.com>
1060
1061      initial
1062  ---
1063   one | 1 +
1064   1 file changed, 1 insertion(+)
1065
1066  diff --git a/one b/one
1067  new file mode 100644
1068  index 0000000..5626abf
1069  --- /dev/null
1070  +++ b/one
1071  @@ -0,0 +1 @@
1072  +one
1073EOF
1074
1075sanitize_output () {
1076        sed -e 's/ *$//' \
1077            -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
1078            -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
1079            -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
1080            -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
1081            -e 's/, 0 deletions(-)//' \
1082            -e 's/, 0 insertions(+)//' \
1083            -e 's/ 1 files changed, / 1 file changed, /' \
1084            -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
1085            -e 's/, 1 insertions(+)/, 1 insertion(+)/'
1086}
1087
1088test_expect_success 'log --graph with diff and stats' '
1089        git log --no-renames --graph --pretty=short --stat -p >actual &&
1090        sanitize_output >actual.sanitized <actual &&
1091        test_i18ncmp expect actual.sanitized
1092'
1093
1094cat >expect <<\EOF
1095*** *   commit COMMIT_OBJECT_NAME
1096*** |\  Merge: MERGE_PARENTS
1097*** | | Author: A U Thor <author@example.com>
1098*** | |
1099*** | |     Merge HEADS DESCRIPTION
1100*** | |
1101*** | * commit COMMIT_OBJECT_NAME
1102*** | | Author: A U Thor <author@example.com>
1103*** | |
1104*** | |     reach
1105*** | | ---
1106*** | |  reach.t | 1 +
1107*** | |  1 file changed, 1 insertion(+)
1108*** | |
1109*** | | diff --git a/reach.t b/reach.t
1110*** | | new file mode 100644
1111*** | | index 0000000..10c9591
1112*** | | --- /dev/null
1113*** | | +++ b/reach.t
1114*** | | @@ -0,0 +1 @@
1115*** | | +reach
1116*** | |
1117*** |  \
1118*** *-. \   commit COMMIT_OBJECT_NAME
1119*** |\ \ \  Merge: MERGE_PARENTS
1120*** | | | | Author: A U Thor <author@example.com>
1121*** | | | |
1122*** | | | |     Merge HEADS DESCRIPTION
1123*** | | | |
1124*** | | * | commit COMMIT_OBJECT_NAME
1125*** | | |/  Author: A U Thor <author@example.com>
1126*** | | |
1127*** | | |       octopus-b
1128*** | | |   ---
1129*** | | |    octopus-b.t | 1 +
1130*** | | |    1 file changed, 1 insertion(+)
1131*** | | |
1132*** | | |   diff --git a/octopus-b.t b/octopus-b.t
1133*** | | |   new file mode 100644
1134*** | | |   index 0000000..d5fcad0
1135*** | | |   --- /dev/null
1136*** | | |   +++ b/octopus-b.t
1137*** | | |   @@ -0,0 +1 @@
1138*** | | |   +octopus-b
1139*** | | |
1140*** | * | commit COMMIT_OBJECT_NAME
1141*** | |/  Author: A U Thor <author@example.com>
1142*** | |
1143*** | |       octopus-a
1144*** | |   ---
1145*** | |    octopus-a.t | 1 +
1146*** | |    1 file changed, 1 insertion(+)
1147*** | |
1148*** | |   diff --git a/octopus-a.t b/octopus-a.t
1149*** | |   new file mode 100644
1150*** | |   index 0000000..11ee015
1151*** | |   --- /dev/null
1152*** | |   +++ b/octopus-a.t
1153*** | |   @@ -0,0 +1 @@
1154*** | |   +octopus-a
1155*** | |
1156*** * | commit COMMIT_OBJECT_NAME
1157*** |/  Author: A U Thor <author@example.com>
1158*** |
1159*** |       seventh
1160*** |   ---
1161*** |    seventh.t | 1 +
1162*** |    1 file changed, 1 insertion(+)
1163*** |
1164*** |   diff --git a/seventh.t b/seventh.t
1165*** |   new file mode 100644
1166*** |   index 0000000..9744ffc
1167*** |   --- /dev/null
1168*** |   +++ b/seventh.t
1169*** |   @@ -0,0 +1 @@
1170*** |   +seventh
1171*** |
1172*** *   commit COMMIT_OBJECT_NAME
1173*** |\  Merge: MERGE_PARENTS
1174*** | | Author: A U Thor <author@example.com>
1175*** | |
1176*** | |     Merge branch 'tangle'
1177*** | |
1178*** | *   commit COMMIT_OBJECT_NAME
1179*** | |\  Merge: MERGE_PARENTS
1180*** | | | Author: A U Thor <author@example.com>
1181*** | | |
1182*** | | |     Merge branch 'side' (early part) into tangle
1183*** | | |
1184*** | * |   commit COMMIT_OBJECT_NAME
1185*** | |\ \  Merge: MERGE_PARENTS
1186*** | | | | Author: A U Thor <author@example.com>
1187*** | | | |
1188*** | | | |     Merge branch 'master' (early part) into tangle
1189*** | | | |
1190*** | * | | commit COMMIT_OBJECT_NAME
1191*** | | | | Author: A U Thor <author@example.com>
1192*** | | | |
1193*** | | | |     tangle-a
1194*** | | | | ---
1195*** | | | |  tangle-a | 1 +
1196*** | | | |  1 file changed, 1 insertion(+)
1197*** | | | |
1198*** | | | | diff --git a/tangle-a b/tangle-a
1199*** | | | | new file mode 100644
1200*** | | | | index 0000000..7898192
1201*** | | | | --- /dev/null
1202*** | | | | +++ b/tangle-a
1203*** | | | | @@ -0,0 +1 @@
1204*** | | | | +a
1205*** | | | |
1206*** * | | |   commit COMMIT_OBJECT_NAME
1207*** |\ \ \ \  Merge: MERGE_PARENTS
1208*** | | | | | Author: A U Thor <author@example.com>
1209*** | | | | |
1210*** | | | | |     Merge branch 'side'
1211*** | | | | |
1212*** | * | | | commit COMMIT_OBJECT_NAME
1213*** | | |_|/  Author: A U Thor <author@example.com>
1214*** | |/| |
1215*** | | | |       side-2
1216*** | | | |   ---
1217*** | | | |    2 | 1 +
1218*** | | | |    1 file changed, 1 insertion(+)
1219*** | | | |
1220*** | | | |   diff --git a/2 b/2
1221*** | | | |   new file mode 100644
1222*** | | | |   index 0000000..0cfbf08
1223*** | | | |   --- /dev/null
1224*** | | | |   +++ b/2
1225*** | | | |   @@ -0,0 +1 @@
1226*** | | | |   +2
1227*** | | | |
1228*** | * | | commit COMMIT_OBJECT_NAME
1229*** | | | | Author: A U Thor <author@example.com>
1230*** | | | |
1231*** | | | |     side-1
1232*** | | | | ---
1233*** | | | |  1 | 1 +
1234*** | | | |  1 file changed, 1 insertion(+)
1235*** | | | |
1236*** | | | | diff --git a/1 b/1
1237*** | | | | new file mode 100644
1238*** | | | | index 0000000..d00491f
1239*** | | | | --- /dev/null
1240*** | | | | +++ b/1
1241*** | | | | @@ -0,0 +1 @@
1242*** | | | | +1
1243*** | | | |
1244*** * | | | commit COMMIT_OBJECT_NAME
1245*** | | | | Author: A U Thor <author@example.com>
1246*** | | | |
1247*** | | | |     Second
1248*** | | | | ---
1249*** | | | |  one | 1 +
1250*** | | | |  1 file changed, 1 insertion(+)
1251*** | | | |
1252*** | | | | diff --git a/one b/one
1253*** | | | | new file mode 100644
1254*** | | | | index 0000000..9a33383
1255*** | | | | --- /dev/null
1256*** | | | | +++ b/one
1257*** | | | | @@ -0,0 +1 @@
1258*** | | | | +case
1259*** | | | |
1260*** * | | | commit COMMIT_OBJECT_NAME
1261*** | |_|/  Author: A U Thor <author@example.com>
1262*** |/| |
1263*** | | |       sixth
1264*** | | |   ---
1265*** | | |    a/two | 1 -
1266*** | | |    1 file changed, 1 deletion(-)
1267*** | | |
1268*** | | |   diff --git a/a/two b/a/two
1269*** | | |   deleted file mode 100644
1270*** | | |   index 9245af5..0000000
1271*** | | |   --- a/a/two
1272*** | | |   +++ /dev/null
1273*** | | |   @@ -1 +0,0 @@
1274*** | | |   -ni
1275*** | | |
1276*** * | | commit COMMIT_OBJECT_NAME
1277*** | | | Author: A U Thor <author@example.com>
1278*** | | |
1279*** | | |     fifth
1280*** | | | ---
1281*** | | |  a/two | 1 +
1282*** | | |  1 file changed, 1 insertion(+)
1283*** | | |
1284*** | | | diff --git a/a/two b/a/two
1285*** | | | new file mode 100644
1286*** | | | index 0000000..9245af5
1287*** | | | --- /dev/null
1288*** | | | +++ b/a/two
1289*** | | | @@ -0,0 +1 @@
1290*** | | | +ni
1291*** | | |
1292*** * | | commit COMMIT_OBJECT_NAME
1293*** |/ /  Author: A U Thor <author@example.com>
1294*** | |
1295*** | |       fourth
1296*** | |   ---
1297*** | |    ein | 1 +
1298*** | |    1 file changed, 1 insertion(+)
1299*** | |
1300*** | |   diff --git a/ein b/ein
1301*** | |   new file mode 100644
1302*** | |   index 0000000..9d7e69f
1303*** | |   --- /dev/null
1304*** | |   +++ b/ein
1305*** | |   @@ -0,0 +1 @@
1306*** | |   +ichi
1307*** | |
1308*** * | commit COMMIT_OBJECT_NAME
1309*** |/  Author: A U Thor <author@example.com>
1310*** |
1311*** |       third
1312*** |   ---
1313*** |    ichi | 1 +
1314*** |    one  | 1 -
1315*** |    2 files changed, 1 insertion(+), 1 deletion(-)
1316*** |
1317*** |   diff --git a/ichi b/ichi
1318*** |   new file mode 100644
1319*** |   index 0000000..9d7e69f
1320*** |   --- /dev/null
1321*** |   +++ b/ichi
1322*** |   @@ -0,0 +1 @@
1323*** |   +ichi
1324*** |   diff --git a/one b/one
1325*** |   deleted file mode 100644
1326*** |   index 9d7e69f..0000000
1327*** |   --- a/one
1328*** |   +++ /dev/null
1329*** |   @@ -1 +0,0 @@
1330*** |   -ichi
1331*** |
1332*** * commit COMMIT_OBJECT_NAME
1333*** | Author: A U Thor <author@example.com>
1334*** |
1335*** |     second
1336*** | ---
1337*** |  one | 2 +-
1338*** |  1 file changed, 1 insertion(+), 1 deletion(-)
1339*** |
1340*** | diff --git a/one b/one
1341*** | index 5626abf..9d7e69f 100644
1342*** | --- a/one
1343*** | +++ b/one
1344*** | @@ -1 +1 @@
1345*** | -one
1346*** | +ichi
1347*** |
1348*** * commit COMMIT_OBJECT_NAME
1349***   Author: A U Thor <author@example.com>
1350***
1351***       initial
1352***   ---
1353***    one | 1 +
1354***    1 file changed, 1 insertion(+)
1355***
1356***   diff --git a/one b/one
1357***   new file mode 100644
1358***   index 0000000..5626abf
1359***   --- /dev/null
1360***   +++ b/one
1361***   @@ -0,0 +1 @@
1362***   +one
1363EOF
1364
1365test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1366        git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
1367        sanitize_output >actual.sanitized <actual &&
1368        test_i18ncmp expect actual.sanitized
1369'
1370
1371cat >expect <<-\EOF
1372* reach
1373|
1374| A     reach.t
1375* Merge branch 'tangle'
1376*   Merge branch 'side'
1377|\
1378| * side-2
1379|
1380|   A   2
1381* Second
1382|
1383| A     one
1384* sixth
1385
1386  D     a/two
1387EOF
1388
1389test_expect_success 'log --graph with --name-status' '
1390        git log --graph --format=%s --name-status tangle..reach >actual &&
1391        sanitize_output <actual >actual.sanitized &&
1392        test_cmp expect actual.sanitized
1393'
1394
1395cat >expect <<-\EOF
1396* reach
1397|
1398| reach.t
1399* Merge branch 'tangle'
1400*   Merge branch 'side'
1401|\
1402| * side-2
1403|
1404|   2
1405* Second
1406|
1407| one
1408* sixth
1409
1410  a/two
1411EOF
1412
1413test_expect_success 'log --graph with --name-only' '
1414        git log --graph --format=%s --name-only tangle..reach >actual &&
1415        sanitize_output <actual >actual.sanitized &&
1416        test_cmp expect actual.sanitized
1417'
1418
1419test_expect_success 'dotdot is a parent directory' '
1420        mkdir -p a/b &&
1421        ( echo sixth && echo fifth ) >expect &&
1422        ( cd a/b && git log --format=%s .. ) >actual &&
1423        test_cmp expect actual
1424'
1425
1426test_expect_success GPG 'setup signed branch' '
1427        test_when_finished "git reset --hard && git checkout master" &&
1428        git checkout -b signed master &&
1429        echo foo >foo &&
1430        git add foo &&
1431        git commit -S -m signed_commit
1432'
1433
1434test_expect_success GPG 'log --graph --show-signature' '
1435        git log --graph --show-signature -n1 signed >actual &&
1436        grep "^| gpg: Signature made" actual &&
1437        grep "^| gpg: Good signature" actual
1438'
1439
1440test_expect_success GPG 'log --graph --show-signature for merged tag' '
1441        test_when_finished "git reset --hard && git checkout master" &&
1442        git checkout -b plain master &&
1443        echo aaa >bar &&
1444        git add bar &&
1445        git commit -m bar_commit &&
1446        git checkout -b tagged master &&
1447        echo bbb >baz &&
1448        git add baz &&
1449        git commit -m baz_commit &&
1450        git tag -s -m signed_tag_msg signed_tag &&
1451        git checkout plain &&
1452        git merge --no-ff -m msg signed_tag &&
1453        git log --graph --show-signature -n1 plain >actual &&
1454        grep "^|\\\  merged tag" actual &&
1455        grep "^| | gpg: Signature made" actual &&
1456        grep "^| | gpg: Good signature" actual
1457'
1458
1459test_expect_success GPG '--no-show-signature overrides --show-signature' '
1460        git log -1 --show-signature --no-show-signature signed >actual &&
1461        ! grep "^gpg:" actual
1462'
1463
1464test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1465        test_config log.showsignature true &&
1466        git log -1 signed >actual &&
1467        grep "gpg: Signature made" actual &&
1468        grep "gpg: Good signature" actual
1469'
1470
1471test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1472        test_config log.showsignature true &&
1473        git log -1 --no-show-signature signed >actual &&
1474        ! grep "^gpg:" actual
1475'
1476
1477test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1478        test_config log.showsignature false &&
1479        git log -1 --show-signature signed >actual &&
1480        grep "gpg: Signature made" actual &&
1481        grep "gpg: Good signature" actual
1482'
1483
1484test_expect_success 'log --graph --no-walk is forbidden' '
1485        test_must_fail git log --graph --no-walk
1486'
1487
1488test_expect_success 'log diagnoses bogus HEAD' '
1489        git init empty &&
1490        test_must_fail git -C empty log 2>stderr &&
1491        test_i18ngrep does.not.have.any.commits stderr &&
1492        echo 1234abcd >empty/.git/refs/heads/master &&
1493        test_must_fail git -C empty log 2>stderr &&
1494        test_i18ngrep broken stderr &&
1495        echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1496        test_must_fail git -C empty log 2>stderr &&
1497        test_i18ngrep broken stderr &&
1498        test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1499        test_i18ngrep broken stderr
1500'
1501
1502test_expect_success 'set up --source tests' '
1503        git checkout --orphan source-a &&
1504        test_commit one &&
1505        test_commit two &&
1506        git checkout -b source-b HEAD^ &&
1507        test_commit three
1508'
1509
1510test_expect_success 'log --source paints branch names' '
1511        cat >expect <<-\EOF &&
1512        09e12a9 source-b three
1513        8e393e1 source-a two
1514        1ac6c77 source-b one
1515        EOF
1516        git log --oneline --source source-a source-b >actual &&
1517        test_cmp expect actual
1518'
1519
1520test_expect_success 'log --source paints tag names' '
1521        git tag -m tagged source-tag &&
1522        cat >expect <<-\EOF &&
1523        09e12a9 source-tag three
1524        8e393e1 source-a two
1525        1ac6c77 source-tag one
1526        EOF
1527        git log --oneline --source source-tag source-a >actual &&
1528        test_cmp expect actual
1529'
1530
1531test_done