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