t / t4202-log.shon commit log: make --regexp-ignore-case work with --perl-regexp (9e3cbc5)
   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
 422                fi &&
 423                test_cmp expect.fixed actual.fixed.long-arg &&
 424                test_cmp expect.basic actual.basic.long-arg &&
 425                test_cmp expect.extended actual.extended.long-arg
 426        )
 427'
 428
 429cat > expect <<EOF
 430* Second
 431* sixth
 432* fifth
 433* fourth
 434* third
 435* second
 436* initial
 437EOF
 438
 439test_expect_success 'simple log --graph' '
 440        git log --graph --pretty=tformat:%s >actual &&
 441        test_cmp expect actual
 442'
 443
 444cat > expect <<EOF
 445123 * Second
 446123 * sixth
 447123 * fifth
 448123 * fourth
 449123 * third
 450123 * second
 451123 * initial
 452EOF
 453
 454test_expect_success 'simple log --graph --line-prefix="123 "' '
 455        git log --graph --line-prefix="123 " --pretty=tformat:%s >actual &&
 456        test_cmp expect actual
 457'
 458
 459test_expect_success 'set up merge history' '
 460        git checkout -b side HEAD~4 &&
 461        test_commit side-1 1 1 &&
 462        test_commit side-2 2 2 &&
 463        git checkout master &&
 464        git merge side
 465'
 466
 467cat > expect <<\EOF
 468*   Merge branch 'side'
 469|\
 470| * side-2
 471| * side-1
 472* | Second
 473* | sixth
 474* | fifth
 475* | fourth
 476|/
 477* third
 478* second
 479* initial
 480EOF
 481
 482test_expect_success 'log --graph with merge' '
 483        git log --graph --date-order --pretty=tformat:%s |
 484                sed "s/ *\$//" >actual &&
 485        test_cmp expect actual
 486'
 487
 488cat > expect <<\EOF
 489| | | *   Merge branch 'side'
 490| | | |\
 491| | | | * side-2
 492| | | | * side-1
 493| | | * | Second
 494| | | * | sixth
 495| | | * | fifth
 496| | | * | fourth
 497| | | |/
 498| | | * third
 499| | | * second
 500| | | * initial
 501EOF
 502
 503test_expect_success 'log --graph --line-prefix="| | | " with merge' '
 504        git log --line-prefix="| | | " --graph --date-order --pretty=tformat:%s |
 505                sed "s/ *\$//" >actual &&
 506        test_cmp expect actual
 507'
 508
 509cat > expect.colors <<\EOF
 510*   Merge branch 'side'
 511<BLUE>|<RESET><CYAN>\<RESET>
 512<BLUE>|<RESET> * side-2
 513<BLUE>|<RESET> * side-1
 514* <CYAN>|<RESET> Second
 515* <CYAN>|<RESET> sixth
 516* <CYAN>|<RESET> fifth
 517* <CYAN>|<RESET> fourth
 518<CYAN>|<RESET><CYAN>/<RESET>
 519* third
 520* second
 521* initial
 522EOF
 523
 524test_expect_success 'log --graph with merge with log.graphColors' '
 525        test_config log.graphColors " blue,invalid-color, cyan, red  , " &&
 526        git log --color=always --graph --date-order --pretty=tformat:%s |
 527                test_decode_color | sed "s/ *\$//" >actual &&
 528        test_cmp expect.colors actual
 529'
 530
 531test_expect_success 'log --raw --graph -m with merge' '
 532        git log --raw --graph --oneline -m master | head -n 500 >actual &&
 533        grep "initial" actual
 534'
 535
 536test_expect_success 'diff-tree --graph' '
 537        git diff-tree --graph master^ | head -n 500 >actual &&
 538        grep "one" actual
 539'
 540
 541cat > expect <<\EOF
 542*   commit master
 543|\  Merge: A B
 544| | Author: A U Thor <author@example.com>
 545| |
 546| |     Merge branch 'side'
 547| |
 548| * commit side
 549| | Author: A U Thor <author@example.com>
 550| |
 551| |     side-2
 552| |
 553| * commit tags/side-1
 554| | Author: A U Thor <author@example.com>
 555| |
 556| |     side-1
 557| |
 558* | commit master~1
 559| | Author: A U Thor <author@example.com>
 560| |
 561| |     Second
 562| |
 563* | commit master~2
 564| | Author: A U Thor <author@example.com>
 565| |
 566| |     sixth
 567| |
 568* | commit master~3
 569| | Author: A U Thor <author@example.com>
 570| |
 571| |     fifth
 572| |
 573* | commit master~4
 574|/  Author: A U Thor <author@example.com>
 575|
 576|       fourth
 577|
 578* commit tags/side-1~1
 579| Author: A U Thor <author@example.com>
 580|
 581|     third
 582|
 583* commit tags/side-1~2
 584| Author: A U Thor <author@example.com>
 585|
 586|     second
 587|
 588* commit tags/side-1~3
 589  Author: A U Thor <author@example.com>
 590
 591      initial
 592EOF
 593
 594test_expect_success 'log --graph with full output' '
 595        git log --graph --date-order --pretty=short |
 596                git name-rev --name-only --stdin |
 597                sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
 598        test_cmp expect actual
 599'
 600
 601test_expect_success 'set up more tangled history' '
 602        git checkout -b tangle HEAD~6 &&
 603        test_commit tangle-a tangle-a a &&
 604        git merge master~3 &&
 605        git merge side~1 &&
 606        git checkout master &&
 607        git merge tangle &&
 608        git checkout -b reach &&
 609        test_commit reach &&
 610        git checkout master &&
 611        git checkout -b octopus-a &&
 612        test_commit octopus-a &&
 613        git checkout master &&
 614        git checkout -b octopus-b &&
 615        test_commit octopus-b &&
 616        git checkout master &&
 617        test_commit seventh &&
 618        git merge octopus-a octopus-b &&
 619        git merge reach
 620'
 621
 622cat > expect <<\EOF
 623*   Merge tag 'reach'
 624|\
 625| \
 626|  \
 627*-. \   Merge tags 'octopus-a' and 'octopus-b'
 628|\ \ \
 629* | | | seventh
 630| | * | octopus-b
 631| |/ /
 632|/| |
 633| * | octopus-a
 634|/ /
 635| * reach
 636|/
 637*   Merge branch 'tangle'
 638|\
 639| *   Merge branch 'side' (early part) into tangle
 640| |\
 641| * \   Merge branch 'master' (early part) into tangle
 642| |\ \
 643| * | | tangle-a
 644* | | |   Merge branch 'side'
 645|\ \ \ \
 646| * | | | side-2
 647| | |_|/
 648| |/| |
 649| * | | side-1
 650* | | | Second
 651* | | | sixth
 652| |_|/
 653|/| |
 654* | | fifth
 655* | | fourth
 656|/ /
 657* | third
 658|/
 659* second
 660* initial
 661EOF
 662
 663test_expect_success 'log --graph with merge' '
 664        git log --graph --date-order --pretty=tformat:%s |
 665                sed "s/ *\$//" >actual &&
 666        test_cmp expect actual
 667'
 668
 669test_expect_success 'log.decorate configuration' '
 670        git log --oneline --no-decorate >expect.none &&
 671        git log --oneline --decorate >expect.short &&
 672        git log --oneline --decorate=full >expect.full &&
 673
 674        echo "[log] decorate" >>.git/config &&
 675        git log --oneline >actual &&
 676        test_cmp expect.short actual &&
 677
 678        test_config log.decorate true &&
 679        git log --oneline >actual &&
 680        test_cmp expect.short actual &&
 681        git log --oneline --decorate=full >actual &&
 682        test_cmp expect.full actual &&
 683        git log --oneline --decorate=no >actual &&
 684        test_cmp expect.none actual &&
 685
 686        test_config log.decorate no &&
 687        git log --oneline >actual &&
 688        test_cmp expect.none actual &&
 689        git log --oneline --decorate >actual &&
 690        test_cmp expect.short actual &&
 691        git log --oneline --decorate=full >actual &&
 692        test_cmp expect.full actual &&
 693
 694        test_config log.decorate 1 &&
 695        git log --oneline >actual &&
 696        test_cmp expect.short actual &&
 697        git log --oneline --decorate=full >actual &&
 698        test_cmp expect.full actual &&
 699        git log --oneline --decorate=no >actual &&
 700        test_cmp expect.none actual &&
 701
 702        test_config log.decorate short &&
 703        git log --oneline >actual &&
 704        test_cmp expect.short actual &&
 705        git log --oneline --no-decorate >actual &&
 706        test_cmp expect.none actual &&
 707        git log --oneline --decorate=full >actual &&
 708        test_cmp expect.full actual &&
 709
 710        test_config log.decorate full &&
 711        git log --oneline >actual &&
 712        test_cmp expect.full actual &&
 713        git log --oneline --no-decorate >actual &&
 714        test_cmp expect.none actual &&
 715        git log --oneline --decorate >actual &&
 716        test_cmp expect.short actual &&
 717
 718        test_unconfig log.decorate &&
 719        git log --pretty=raw >expect.raw &&
 720        test_config log.decorate full &&
 721        git log --pretty=raw >actual &&
 722        test_cmp expect.raw actual
 723
 724'
 725
 726test_expect_success TTY 'log output on a TTY' '
 727        git log --oneline --decorate >expect.short &&
 728
 729        test_terminal git log --oneline >actual &&
 730        test_cmp expect.short actual
 731'
 732
 733test_expect_success 'reflog is expected format' '
 734        git log -g --abbrev-commit --pretty=oneline >expect &&
 735        git reflog >actual &&
 736        test_cmp expect actual
 737'
 738
 739test_expect_success 'whatchanged is expected format' '
 740        git log --no-merges --raw >expect &&
 741        git whatchanged >actual &&
 742        test_cmp expect actual
 743'
 744
 745test_expect_success 'log.abbrevCommit configuration' '
 746        git log --abbrev-commit >expect.log.abbrev &&
 747        git log --no-abbrev-commit >expect.log.full &&
 748        git log --pretty=raw >expect.log.raw &&
 749        git reflog --abbrev-commit >expect.reflog.abbrev &&
 750        git reflog --no-abbrev-commit >expect.reflog.full &&
 751        git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
 752        git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
 753
 754        test_config log.abbrevCommit true &&
 755
 756        git log >actual &&
 757        test_cmp expect.log.abbrev actual &&
 758        git log --no-abbrev-commit >actual &&
 759        test_cmp expect.log.full actual &&
 760
 761        git log --pretty=raw >actual &&
 762        test_cmp expect.log.raw actual &&
 763
 764        git reflog >actual &&
 765        test_cmp expect.reflog.abbrev actual &&
 766        git reflog --no-abbrev-commit >actual &&
 767        test_cmp expect.reflog.full actual &&
 768
 769        git whatchanged >actual &&
 770        test_cmp expect.whatchanged.abbrev actual &&
 771        git whatchanged --no-abbrev-commit >actual &&
 772        test_cmp expect.whatchanged.full actual
 773'
 774
 775test_expect_success 'show added path under "--follow -M"' '
 776        # This tests for a regression introduced in v1.7.2-rc0~103^2~2
 777        test_create_repo regression &&
 778        (
 779                cd regression &&
 780                test_commit needs-another-commit &&
 781                test_commit foo.bar &&
 782                git log -M --follow -p foo.bar.t &&
 783                git log -M --follow --stat foo.bar.t &&
 784                git log -M --follow --name-only foo.bar.t
 785        )
 786'
 787
 788test_expect_success 'git log -c --follow' '
 789        test_create_repo follow-c &&
 790        (
 791                cd follow-c &&
 792                test_commit initial file original &&
 793                git rm file &&
 794                test_commit rename file2 original &&
 795                git reset --hard initial &&
 796                test_commit modify file foo &&
 797                git merge -m merge rename &&
 798                git log -c --follow file2
 799        )
 800'
 801
 802cat >expect <<\EOF
 803*   commit COMMIT_OBJECT_NAME
 804|\  Merge: MERGE_PARENTS
 805| | Author: A U Thor <author@example.com>
 806| |
 807| |     Merge HEADS DESCRIPTION
 808| |
 809| * commit COMMIT_OBJECT_NAME
 810| | Author: A U Thor <author@example.com>
 811| |
 812| |     reach
 813| | ---
 814| |  reach.t | 1 +
 815| |  1 file changed, 1 insertion(+)
 816| |
 817| | diff --git a/reach.t b/reach.t
 818| | new file mode 100644
 819| | index 0000000..10c9591
 820| | --- /dev/null
 821| | +++ b/reach.t
 822| | @@ -0,0 +1 @@
 823| | +reach
 824| |
 825|  \
 826*-. \   commit COMMIT_OBJECT_NAME
 827|\ \ \  Merge: MERGE_PARENTS
 828| | | | Author: A U Thor <author@example.com>
 829| | | |
 830| | | |     Merge HEADS DESCRIPTION
 831| | | |
 832| | * | commit COMMIT_OBJECT_NAME
 833| | |/  Author: A U Thor <author@example.com>
 834| | |
 835| | |       octopus-b
 836| | |   ---
 837| | |    octopus-b.t | 1 +
 838| | |    1 file changed, 1 insertion(+)
 839| | |
 840| | |   diff --git a/octopus-b.t b/octopus-b.t
 841| | |   new file mode 100644
 842| | |   index 0000000..d5fcad0
 843| | |   --- /dev/null
 844| | |   +++ b/octopus-b.t
 845| | |   @@ -0,0 +1 @@
 846| | |   +octopus-b
 847| | |
 848| * | commit COMMIT_OBJECT_NAME
 849| |/  Author: A U Thor <author@example.com>
 850| |
 851| |       octopus-a
 852| |   ---
 853| |    octopus-a.t | 1 +
 854| |    1 file changed, 1 insertion(+)
 855| |
 856| |   diff --git a/octopus-a.t b/octopus-a.t
 857| |   new file mode 100644
 858| |   index 0000000..11ee015
 859| |   --- /dev/null
 860| |   +++ b/octopus-a.t
 861| |   @@ -0,0 +1 @@
 862| |   +octopus-a
 863| |
 864* | commit COMMIT_OBJECT_NAME
 865|/  Author: A U Thor <author@example.com>
 866|
 867|       seventh
 868|   ---
 869|    seventh.t | 1 +
 870|    1 file changed, 1 insertion(+)
 871|
 872|   diff --git a/seventh.t b/seventh.t
 873|   new file mode 100644
 874|   index 0000000..9744ffc
 875|   --- /dev/null
 876|   +++ b/seventh.t
 877|   @@ -0,0 +1 @@
 878|   +seventh
 879|
 880*   commit COMMIT_OBJECT_NAME
 881|\  Merge: MERGE_PARENTS
 882| | Author: A U Thor <author@example.com>
 883| |
 884| |     Merge branch 'tangle'
 885| |
 886| *   commit COMMIT_OBJECT_NAME
 887| |\  Merge: MERGE_PARENTS
 888| | | Author: A U Thor <author@example.com>
 889| | |
 890| | |     Merge branch 'side' (early part) into tangle
 891| | |
 892| * |   commit COMMIT_OBJECT_NAME
 893| |\ \  Merge: MERGE_PARENTS
 894| | | | Author: A U Thor <author@example.com>
 895| | | |
 896| | | |     Merge branch 'master' (early part) into tangle
 897| | | |
 898| * | | commit COMMIT_OBJECT_NAME
 899| | | | Author: A U Thor <author@example.com>
 900| | | |
 901| | | |     tangle-a
 902| | | | ---
 903| | | |  tangle-a | 1 +
 904| | | |  1 file changed, 1 insertion(+)
 905| | | |
 906| | | | diff --git a/tangle-a b/tangle-a
 907| | | | new file mode 100644
 908| | | | index 0000000..7898192
 909| | | | --- /dev/null
 910| | | | +++ b/tangle-a
 911| | | | @@ -0,0 +1 @@
 912| | | | +a
 913| | | |
 914* | | |   commit COMMIT_OBJECT_NAME
 915|\ \ \ \  Merge: MERGE_PARENTS
 916| | | | | Author: A U Thor <author@example.com>
 917| | | | |
 918| | | | |     Merge branch 'side'
 919| | | | |
 920| * | | | commit COMMIT_OBJECT_NAME
 921| | |_|/  Author: A U Thor <author@example.com>
 922| |/| |
 923| | | |       side-2
 924| | | |   ---
 925| | | |    2 | 1 +
 926| | | |    1 file changed, 1 insertion(+)
 927| | | |
 928| | | |   diff --git a/2 b/2
 929| | | |   new file mode 100644
 930| | | |   index 0000000..0cfbf08
 931| | | |   --- /dev/null
 932| | | |   +++ b/2
 933| | | |   @@ -0,0 +1 @@
 934| | | |   +2
 935| | | |
 936| * | | commit COMMIT_OBJECT_NAME
 937| | | | Author: A U Thor <author@example.com>
 938| | | |
 939| | | |     side-1
 940| | | | ---
 941| | | |  1 | 1 +
 942| | | |  1 file changed, 1 insertion(+)
 943| | | |
 944| | | | diff --git a/1 b/1
 945| | | | new file mode 100644
 946| | | | index 0000000..d00491f
 947| | | | --- /dev/null
 948| | | | +++ b/1
 949| | | | @@ -0,0 +1 @@
 950| | | | +1
 951| | | |
 952* | | | commit COMMIT_OBJECT_NAME
 953| | | | Author: A U Thor <author@example.com>
 954| | | |
 955| | | |     Second
 956| | | | ---
 957| | | |  one | 1 +
 958| | | |  1 file changed, 1 insertion(+)
 959| | | |
 960| | | | diff --git a/one b/one
 961| | | | new file mode 100644
 962| | | | index 0000000..9a33383
 963| | | | --- /dev/null
 964| | | | +++ b/one
 965| | | | @@ -0,0 +1 @@
 966| | | | +case
 967| | | |
 968* | | | commit COMMIT_OBJECT_NAME
 969| |_|/  Author: A U Thor <author@example.com>
 970|/| |
 971| | |       sixth
 972| | |   ---
 973| | |    a/two | 1 -
 974| | |    1 file changed, 1 deletion(-)
 975| | |
 976| | |   diff --git a/a/two b/a/two
 977| | |   deleted file mode 100644
 978| | |   index 9245af5..0000000
 979| | |   --- a/a/two
 980| | |   +++ /dev/null
 981| | |   @@ -1 +0,0 @@
 982| | |   -ni
 983| | |
 984* | | commit COMMIT_OBJECT_NAME
 985| | | Author: A U Thor <author@example.com>
 986| | |
 987| | |     fifth
 988| | | ---
 989| | |  a/two | 1 +
 990| | |  1 file changed, 1 insertion(+)
 991| | |
 992| | | diff --git a/a/two b/a/two
 993| | | new file mode 100644
 994| | | index 0000000..9245af5
 995| | | --- /dev/null
 996| | | +++ b/a/two
 997| | | @@ -0,0 +1 @@
 998| | | +ni
 999| | |
1000* | | commit COMMIT_OBJECT_NAME
1001|/ /  Author: A U Thor <author@example.com>
1002| |
1003| |       fourth
1004| |   ---
1005| |    ein | 1 +
1006| |    1 file changed, 1 insertion(+)
1007| |
1008| |   diff --git a/ein b/ein
1009| |   new file mode 100644
1010| |   index 0000000..9d7e69f
1011| |   --- /dev/null
1012| |   +++ b/ein
1013| |   @@ -0,0 +1 @@
1014| |   +ichi
1015| |
1016* | commit COMMIT_OBJECT_NAME
1017|/  Author: A U Thor <author@example.com>
1018|
1019|       third
1020|   ---
1021|    ichi | 1 +
1022|    one  | 1 -
1023|    2 files changed, 1 insertion(+), 1 deletion(-)
1024|
1025|   diff --git a/ichi b/ichi
1026|   new file mode 100644
1027|   index 0000000..9d7e69f
1028|   --- /dev/null
1029|   +++ b/ichi
1030|   @@ -0,0 +1 @@
1031|   +ichi
1032|   diff --git a/one b/one
1033|   deleted file mode 100644
1034|   index 9d7e69f..0000000
1035|   --- a/one
1036|   +++ /dev/null
1037|   @@ -1 +0,0 @@
1038|   -ichi
1039|
1040* commit COMMIT_OBJECT_NAME
1041| Author: A U Thor <author@example.com>
1042|
1043|     second
1044| ---
1045|  one | 2 +-
1046|  1 file changed, 1 insertion(+), 1 deletion(-)
1047|
1048| diff --git a/one b/one
1049| index 5626abf..9d7e69f 100644
1050| --- a/one
1051| +++ b/one
1052| @@ -1 +1 @@
1053| -one
1054| +ichi
1055|
1056* commit COMMIT_OBJECT_NAME
1057  Author: A U Thor <author@example.com>
1058
1059      initial
1060  ---
1061   one | 1 +
1062   1 file changed, 1 insertion(+)
1063
1064  diff --git a/one b/one
1065  new file mode 100644
1066  index 0000000..5626abf
1067  --- /dev/null
1068  +++ b/one
1069  @@ -0,0 +1 @@
1070  +one
1071EOF
1072
1073sanitize_output () {
1074        sed -e 's/ *$//' \
1075            -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
1076            -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
1077            -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
1078            -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
1079            -e 's/, 0 deletions(-)//' \
1080            -e 's/, 0 insertions(+)//' \
1081            -e 's/ 1 files changed, / 1 file changed, /' \
1082            -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
1083            -e 's/, 1 insertions(+)/, 1 insertion(+)/'
1084}
1085
1086test_expect_success 'log --graph with diff and stats' '
1087        git log --no-renames --graph --pretty=short --stat -p >actual &&
1088        sanitize_output >actual.sanitized <actual &&
1089        test_i18ncmp expect actual.sanitized
1090'
1091
1092cat >expect <<\EOF
1093*** *   commit COMMIT_OBJECT_NAME
1094*** |\  Merge: MERGE_PARENTS
1095*** | | Author: A U Thor <author@example.com>
1096*** | |
1097*** | |     Merge HEADS DESCRIPTION
1098*** | |
1099*** | * commit COMMIT_OBJECT_NAME
1100*** | | Author: A U Thor <author@example.com>
1101*** | |
1102*** | |     reach
1103*** | | ---
1104*** | |  reach.t | 1 +
1105*** | |  1 file changed, 1 insertion(+)
1106*** | |
1107*** | | diff --git a/reach.t b/reach.t
1108*** | | new file mode 100644
1109*** | | index 0000000..10c9591
1110*** | | --- /dev/null
1111*** | | +++ b/reach.t
1112*** | | @@ -0,0 +1 @@
1113*** | | +reach
1114*** | |
1115*** |  \
1116*** *-. \   commit COMMIT_OBJECT_NAME
1117*** |\ \ \  Merge: MERGE_PARENTS
1118*** | | | | Author: A U Thor <author@example.com>
1119*** | | | |
1120*** | | | |     Merge HEADS DESCRIPTION
1121*** | | | |
1122*** | | * | commit COMMIT_OBJECT_NAME
1123*** | | |/  Author: A U Thor <author@example.com>
1124*** | | |
1125*** | | |       octopus-b
1126*** | | |   ---
1127*** | | |    octopus-b.t | 1 +
1128*** | | |    1 file changed, 1 insertion(+)
1129*** | | |
1130*** | | |   diff --git a/octopus-b.t b/octopus-b.t
1131*** | | |   new file mode 100644
1132*** | | |   index 0000000..d5fcad0
1133*** | | |   --- /dev/null
1134*** | | |   +++ b/octopus-b.t
1135*** | | |   @@ -0,0 +1 @@
1136*** | | |   +octopus-b
1137*** | | |
1138*** | * | commit COMMIT_OBJECT_NAME
1139*** | |/  Author: A U Thor <author@example.com>
1140*** | |
1141*** | |       octopus-a
1142*** | |   ---
1143*** | |    octopus-a.t | 1 +
1144*** | |    1 file changed, 1 insertion(+)
1145*** | |
1146*** | |   diff --git a/octopus-a.t b/octopus-a.t
1147*** | |   new file mode 100644
1148*** | |   index 0000000..11ee015
1149*** | |   --- /dev/null
1150*** | |   +++ b/octopus-a.t
1151*** | |   @@ -0,0 +1 @@
1152*** | |   +octopus-a
1153*** | |
1154*** * | commit COMMIT_OBJECT_NAME
1155*** |/  Author: A U Thor <author@example.com>
1156*** |
1157*** |       seventh
1158*** |   ---
1159*** |    seventh.t | 1 +
1160*** |    1 file changed, 1 insertion(+)
1161*** |
1162*** |   diff --git a/seventh.t b/seventh.t
1163*** |   new file mode 100644
1164*** |   index 0000000..9744ffc
1165*** |   --- /dev/null
1166*** |   +++ b/seventh.t
1167*** |   @@ -0,0 +1 @@
1168*** |   +seventh
1169*** |
1170*** *   commit COMMIT_OBJECT_NAME
1171*** |\  Merge: MERGE_PARENTS
1172*** | | Author: A U Thor <author@example.com>
1173*** | |
1174*** | |     Merge branch 'tangle'
1175*** | |
1176*** | *   commit COMMIT_OBJECT_NAME
1177*** | |\  Merge: MERGE_PARENTS
1178*** | | | Author: A U Thor <author@example.com>
1179*** | | |
1180*** | | |     Merge branch 'side' (early part) into tangle
1181*** | | |
1182*** | * |   commit COMMIT_OBJECT_NAME
1183*** | |\ \  Merge: MERGE_PARENTS
1184*** | | | | Author: A U Thor <author@example.com>
1185*** | | | |
1186*** | | | |     Merge branch 'master' (early part) into tangle
1187*** | | | |
1188*** | * | | commit COMMIT_OBJECT_NAME
1189*** | | | | Author: A U Thor <author@example.com>
1190*** | | | |
1191*** | | | |     tangle-a
1192*** | | | | ---
1193*** | | | |  tangle-a | 1 +
1194*** | | | |  1 file changed, 1 insertion(+)
1195*** | | | |
1196*** | | | | diff --git a/tangle-a b/tangle-a
1197*** | | | | new file mode 100644
1198*** | | | | index 0000000..7898192
1199*** | | | | --- /dev/null
1200*** | | | | +++ b/tangle-a
1201*** | | | | @@ -0,0 +1 @@
1202*** | | | | +a
1203*** | | | |
1204*** * | | |   commit COMMIT_OBJECT_NAME
1205*** |\ \ \ \  Merge: MERGE_PARENTS
1206*** | | | | | Author: A U Thor <author@example.com>
1207*** | | | | |
1208*** | | | | |     Merge branch 'side'
1209*** | | | | |
1210*** | * | | | commit COMMIT_OBJECT_NAME
1211*** | | |_|/  Author: A U Thor <author@example.com>
1212*** | |/| |
1213*** | | | |       side-2
1214*** | | | |   ---
1215*** | | | |    2 | 1 +
1216*** | | | |    1 file changed, 1 insertion(+)
1217*** | | | |
1218*** | | | |   diff --git a/2 b/2
1219*** | | | |   new file mode 100644
1220*** | | | |   index 0000000..0cfbf08
1221*** | | | |   --- /dev/null
1222*** | | | |   +++ b/2
1223*** | | | |   @@ -0,0 +1 @@
1224*** | | | |   +2
1225*** | | | |
1226*** | * | | commit COMMIT_OBJECT_NAME
1227*** | | | | Author: A U Thor <author@example.com>
1228*** | | | |
1229*** | | | |     side-1
1230*** | | | | ---
1231*** | | | |  1 | 1 +
1232*** | | | |  1 file changed, 1 insertion(+)
1233*** | | | |
1234*** | | | | diff --git a/1 b/1
1235*** | | | | new file mode 100644
1236*** | | | | index 0000000..d00491f
1237*** | | | | --- /dev/null
1238*** | | | | +++ b/1
1239*** | | | | @@ -0,0 +1 @@
1240*** | | | | +1
1241*** | | | |
1242*** * | | | commit COMMIT_OBJECT_NAME
1243*** | | | | Author: A U Thor <author@example.com>
1244*** | | | |
1245*** | | | |     Second
1246*** | | | | ---
1247*** | | | |  one | 1 +
1248*** | | | |  1 file changed, 1 insertion(+)
1249*** | | | |
1250*** | | | | diff --git a/one b/one
1251*** | | | | new file mode 100644
1252*** | | | | index 0000000..9a33383
1253*** | | | | --- /dev/null
1254*** | | | | +++ b/one
1255*** | | | | @@ -0,0 +1 @@
1256*** | | | | +case
1257*** | | | |
1258*** * | | | commit COMMIT_OBJECT_NAME
1259*** | |_|/  Author: A U Thor <author@example.com>
1260*** |/| |
1261*** | | |       sixth
1262*** | | |   ---
1263*** | | |    a/two | 1 -
1264*** | | |    1 file changed, 1 deletion(-)
1265*** | | |
1266*** | | |   diff --git a/a/two b/a/two
1267*** | | |   deleted file mode 100644
1268*** | | |   index 9245af5..0000000
1269*** | | |   --- a/a/two
1270*** | | |   +++ /dev/null
1271*** | | |   @@ -1 +0,0 @@
1272*** | | |   -ni
1273*** | | |
1274*** * | | commit COMMIT_OBJECT_NAME
1275*** | | | Author: A U Thor <author@example.com>
1276*** | | |
1277*** | | |     fifth
1278*** | | | ---
1279*** | | |  a/two | 1 +
1280*** | | |  1 file changed, 1 insertion(+)
1281*** | | |
1282*** | | | diff --git a/a/two b/a/two
1283*** | | | new file mode 100644
1284*** | | | index 0000000..9245af5
1285*** | | | --- /dev/null
1286*** | | | +++ b/a/two
1287*** | | | @@ -0,0 +1 @@
1288*** | | | +ni
1289*** | | |
1290*** * | | commit COMMIT_OBJECT_NAME
1291*** |/ /  Author: A U Thor <author@example.com>
1292*** | |
1293*** | |       fourth
1294*** | |   ---
1295*** | |    ein | 1 +
1296*** | |    1 file changed, 1 insertion(+)
1297*** | |
1298*** | |   diff --git a/ein b/ein
1299*** | |   new file mode 100644
1300*** | |   index 0000000..9d7e69f
1301*** | |   --- /dev/null
1302*** | |   +++ b/ein
1303*** | |   @@ -0,0 +1 @@
1304*** | |   +ichi
1305*** | |
1306*** * | commit COMMIT_OBJECT_NAME
1307*** |/  Author: A U Thor <author@example.com>
1308*** |
1309*** |       third
1310*** |   ---
1311*** |    ichi | 1 +
1312*** |    one  | 1 -
1313*** |    2 files changed, 1 insertion(+), 1 deletion(-)
1314*** |
1315*** |   diff --git a/ichi b/ichi
1316*** |   new file mode 100644
1317*** |   index 0000000..9d7e69f
1318*** |   --- /dev/null
1319*** |   +++ b/ichi
1320*** |   @@ -0,0 +1 @@
1321*** |   +ichi
1322*** |   diff --git a/one b/one
1323*** |   deleted file mode 100644
1324*** |   index 9d7e69f..0000000
1325*** |   --- a/one
1326*** |   +++ /dev/null
1327*** |   @@ -1 +0,0 @@
1328*** |   -ichi
1329*** |
1330*** * commit COMMIT_OBJECT_NAME
1331*** | Author: A U Thor <author@example.com>
1332*** |
1333*** |     second
1334*** | ---
1335*** |  one | 2 +-
1336*** |  1 file changed, 1 insertion(+), 1 deletion(-)
1337*** |
1338*** | diff --git a/one b/one
1339*** | index 5626abf..9d7e69f 100644
1340*** | --- a/one
1341*** | +++ b/one
1342*** | @@ -1 +1 @@
1343*** | -one
1344*** | +ichi
1345*** |
1346*** * commit COMMIT_OBJECT_NAME
1347***   Author: A U Thor <author@example.com>
1348***
1349***       initial
1350***   ---
1351***    one | 1 +
1352***    1 file changed, 1 insertion(+)
1353***
1354***   diff --git a/one b/one
1355***   new file mode 100644
1356***   index 0000000..5626abf
1357***   --- /dev/null
1358***   +++ b/one
1359***   @@ -0,0 +1 @@
1360***   +one
1361EOF
1362
1363test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1364        git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
1365        sanitize_output >actual.sanitized <actual &&
1366        test_i18ncmp expect actual.sanitized
1367'
1368
1369cat >expect <<-\EOF
1370* reach
1371|
1372| A     reach.t
1373* Merge branch 'tangle'
1374*   Merge branch 'side'
1375|\
1376| * side-2
1377|
1378|   A   2
1379* Second
1380|
1381| A     one
1382* sixth
1383
1384  D     a/two
1385EOF
1386
1387test_expect_success 'log --graph with --name-status' '
1388        git log --graph --format=%s --name-status tangle..reach >actual &&
1389        sanitize_output <actual >actual.sanitized &&
1390        test_cmp expect actual.sanitized
1391'
1392
1393cat >expect <<-\EOF
1394* reach
1395|
1396| reach.t
1397* Merge branch 'tangle'
1398*   Merge branch 'side'
1399|\
1400| * side-2
1401|
1402|   2
1403* Second
1404|
1405| one
1406* sixth
1407
1408  a/two
1409EOF
1410
1411test_expect_success 'log --graph with --name-only' '
1412        git log --graph --format=%s --name-only tangle..reach >actual &&
1413        sanitize_output <actual >actual.sanitized &&
1414        test_cmp expect actual.sanitized
1415'
1416
1417test_expect_success 'dotdot is a parent directory' '
1418        mkdir -p a/b &&
1419        ( echo sixth && echo fifth ) >expect &&
1420        ( cd a/b && git log --format=%s .. ) >actual &&
1421        test_cmp expect actual
1422'
1423
1424test_expect_success GPG 'setup signed branch' '
1425        test_when_finished "git reset --hard && git checkout master" &&
1426        git checkout -b signed master &&
1427        echo foo >foo &&
1428        git add foo &&
1429        git commit -S -m signed_commit
1430'
1431
1432test_expect_success GPG 'log --graph --show-signature' '
1433        git log --graph --show-signature -n1 signed >actual &&
1434        grep "^| gpg: Signature made" actual &&
1435        grep "^| gpg: Good signature" actual
1436'
1437
1438test_expect_success GPG 'log --graph --show-signature for merged tag' '
1439        test_when_finished "git reset --hard && git checkout master" &&
1440        git checkout -b plain master &&
1441        echo aaa >bar &&
1442        git add bar &&
1443        git commit -m bar_commit &&
1444        git checkout -b tagged master &&
1445        echo bbb >baz &&
1446        git add baz &&
1447        git commit -m baz_commit &&
1448        git tag -s -m signed_tag_msg signed_tag &&
1449        git checkout plain &&
1450        git merge --no-ff -m msg signed_tag &&
1451        git log --graph --show-signature -n1 plain >actual &&
1452        grep "^|\\\  merged tag" actual &&
1453        grep "^| | gpg: Signature made" actual &&
1454        grep "^| | gpg: Good signature" actual
1455'
1456
1457test_expect_success GPG '--no-show-signature overrides --show-signature' '
1458        git log -1 --show-signature --no-show-signature signed >actual &&
1459        ! grep "^gpg:" actual
1460'
1461
1462test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1463        test_config log.showsignature true &&
1464        git log -1 signed >actual &&
1465        grep "gpg: Signature made" actual &&
1466        grep "gpg: Good signature" actual
1467'
1468
1469test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1470        test_config log.showsignature true &&
1471        git log -1 --no-show-signature signed >actual &&
1472        ! grep "^gpg:" actual
1473'
1474
1475test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1476        test_config log.showsignature false &&
1477        git log -1 --show-signature signed >actual &&
1478        grep "gpg: Signature made" actual &&
1479        grep "gpg: Good signature" actual
1480'
1481
1482test_expect_success 'log --graph --no-walk is forbidden' '
1483        test_must_fail git log --graph --no-walk
1484'
1485
1486test_expect_success 'log diagnoses bogus HEAD' '
1487        git init empty &&
1488        test_must_fail git -C empty log 2>stderr &&
1489        test_i18ngrep does.not.have.any.commits stderr &&
1490        echo 1234abcd >empty/.git/refs/heads/master &&
1491        test_must_fail git -C empty log 2>stderr &&
1492        test_i18ngrep broken stderr &&
1493        echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1494        test_must_fail git -C empty log 2>stderr &&
1495        test_i18ngrep broken stderr &&
1496        test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1497        test_i18ngrep broken stderr
1498'
1499
1500test_expect_success 'set up --source tests' '
1501        git checkout --orphan source-a &&
1502        test_commit one &&
1503        test_commit two &&
1504        git checkout -b source-b HEAD^ &&
1505        test_commit three
1506'
1507
1508test_expect_success 'log --source paints branch names' '
1509        cat >expect <<-\EOF &&
1510        09e12a9 source-b three
1511        8e393e1 source-a two
1512        1ac6c77 source-b one
1513        EOF
1514        git log --oneline --source source-a source-b >actual &&
1515        test_cmp expect actual
1516'
1517
1518test_expect_success 'log --source paints tag names' '
1519        git tag -m tagged source-tag &&
1520        cat >expect <<-\EOF &&
1521        09e12a9 source-tag three
1522        8e393e1 source-a two
1523        1ac6c77 source-tag one
1524        EOF
1525        git log --oneline --source source-tag source-a >actual &&
1526        test_cmp expect actual
1527'
1528
1529test_done