t / t4202-log.shon commit get_short_sha1: make default disambiguation configurable (5b33cb1)
   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
 362test_expect_success 'log --raw --graph -m with merge' '
 363        git log --raw --graph --oneline -m master | head -n 500 >actual &&
 364        grep "initial" actual
 365'
 366
 367test_expect_success 'diff-tree --graph' '
 368        git diff-tree --graph master^ | head -n 500 >actual &&
 369        grep "one" actual
 370'
 371
 372cat > expect <<\EOF
 373*   commit master
 374|\  Merge: A B
 375| | Author: A U Thor <author@example.com>
 376| |
 377| |     Merge branch 'side'
 378| |
 379| * commit side
 380| | Author: A U Thor <author@example.com>
 381| |
 382| |     side-2
 383| |
 384| * commit tags/side-1
 385| | Author: A U Thor <author@example.com>
 386| |
 387| |     side-1
 388| |
 389* | commit master~1
 390| | Author: A U Thor <author@example.com>
 391| |
 392| |     Second
 393| |
 394* | commit master~2
 395| | Author: A U Thor <author@example.com>
 396| |
 397| |     sixth
 398| |
 399* | commit master~3
 400| | Author: A U Thor <author@example.com>
 401| |
 402| |     fifth
 403| |
 404* | commit master~4
 405|/  Author: A U Thor <author@example.com>
 406|
 407|       fourth
 408|
 409* commit tags/side-1~1
 410| Author: A U Thor <author@example.com>
 411|
 412|     third
 413|
 414* commit tags/side-1~2
 415| Author: A U Thor <author@example.com>
 416|
 417|     second
 418|
 419* commit tags/side-1~3
 420  Author: A U Thor <author@example.com>
 421
 422      initial
 423EOF
 424
 425test_expect_success 'log --graph with full output' '
 426        git log --graph --date-order --pretty=short |
 427                git name-rev --name-only --stdin |
 428                sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
 429        test_cmp expect actual
 430'
 431
 432test_expect_success 'set up more tangled history' '
 433        git checkout -b tangle HEAD~6 &&
 434        test_commit tangle-a tangle-a a &&
 435        git merge master~3 &&
 436        git merge side~1 &&
 437        git checkout master &&
 438        git merge tangle &&
 439        git checkout -b reach &&
 440        test_commit reach &&
 441        git checkout master &&
 442        git checkout -b octopus-a &&
 443        test_commit octopus-a &&
 444        git checkout master &&
 445        git checkout -b octopus-b &&
 446        test_commit octopus-b &&
 447        git checkout master &&
 448        test_commit seventh &&
 449        git merge octopus-a octopus-b &&
 450        git merge reach
 451'
 452
 453cat > expect <<\EOF
 454*   Merge tag 'reach'
 455|\
 456| \
 457|  \
 458*-. \   Merge tags 'octopus-a' and 'octopus-b'
 459|\ \ \
 460* | | | seventh
 461| | * | octopus-b
 462| |/ /
 463|/| |
 464| * | octopus-a
 465|/ /
 466| * reach
 467|/
 468*   Merge branch 'tangle'
 469|\
 470| *   Merge branch 'side' (early part) into tangle
 471| |\
 472| * \   Merge branch 'master' (early part) into tangle
 473| |\ \
 474| * | | tangle-a
 475* | | |   Merge branch 'side'
 476|\ \ \ \
 477| * | | | side-2
 478| | |_|/
 479| |/| |
 480| * | | side-1
 481* | | | Second
 482* | | | sixth
 483| |_|/
 484|/| |
 485* | | fifth
 486* | | fourth
 487|/ /
 488* | third
 489|/
 490* second
 491* initial
 492EOF
 493
 494test_expect_success 'log --graph with merge' '
 495        git log --graph --date-order --pretty=tformat:%s |
 496                sed "s/ *\$//" >actual &&
 497        test_cmp expect actual
 498'
 499
 500test_expect_success 'log.decorate configuration' '
 501        git log --oneline >expect.none &&
 502        git log --oneline --decorate >expect.short &&
 503        git log --oneline --decorate=full >expect.full &&
 504
 505        echo "[log] decorate" >>.git/config &&
 506        git log --oneline >actual &&
 507        test_cmp expect.short actual &&
 508
 509        test_config log.decorate true &&
 510        git log --oneline >actual &&
 511        test_cmp expect.short actual &&
 512        git log --oneline --decorate=full >actual &&
 513        test_cmp expect.full actual &&
 514        git log --oneline --decorate=no >actual &&
 515        test_cmp expect.none actual &&
 516
 517        test_config log.decorate no &&
 518        git log --oneline >actual &&
 519        test_cmp expect.none actual &&
 520        git log --oneline --decorate >actual &&
 521        test_cmp expect.short actual &&
 522        git log --oneline --decorate=full >actual &&
 523        test_cmp expect.full actual &&
 524
 525        test_config log.decorate 1 &&
 526        git log --oneline >actual &&
 527        test_cmp expect.short actual &&
 528        git log --oneline --decorate=full >actual &&
 529        test_cmp expect.full actual &&
 530        git log --oneline --decorate=no >actual &&
 531        test_cmp expect.none actual &&
 532
 533        test_config log.decorate short &&
 534        git log --oneline >actual &&
 535        test_cmp expect.short actual &&
 536        git log --oneline --no-decorate >actual &&
 537        test_cmp expect.none actual &&
 538        git log --oneline --decorate=full >actual &&
 539        test_cmp expect.full actual &&
 540
 541        test_config log.decorate full &&
 542        git log --oneline >actual &&
 543        test_cmp expect.full actual &&
 544        git log --oneline --no-decorate >actual &&
 545        test_cmp expect.none actual &&
 546        git log --oneline --decorate >actual &&
 547        test_cmp expect.short actual &&
 548
 549        test_unconfig log.decorate &&
 550        git log --pretty=raw >expect.raw &&
 551        test_config log.decorate full &&
 552        git log --pretty=raw >actual &&
 553        test_cmp expect.raw actual
 554
 555'
 556
 557test_expect_success 'reflog is expected format' '
 558        git log -g --abbrev-commit --pretty=oneline >expect &&
 559        git reflog >actual &&
 560        test_cmp expect actual
 561'
 562
 563test_expect_success 'whatchanged is expected format' '
 564        git log --no-merges --raw >expect &&
 565        git whatchanged >actual &&
 566        test_cmp expect actual
 567'
 568
 569test_expect_success 'log.abbrevCommit configuration' '
 570        git log --abbrev-commit >expect.log.abbrev &&
 571        git log --no-abbrev-commit >expect.log.full &&
 572        git log --pretty=raw >expect.log.raw &&
 573        git reflog --abbrev-commit >expect.reflog.abbrev &&
 574        git reflog --no-abbrev-commit >expect.reflog.full &&
 575        git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
 576        git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
 577
 578        test_config log.abbrevCommit true &&
 579
 580        git log >actual &&
 581        test_cmp expect.log.abbrev actual &&
 582        git log --no-abbrev-commit >actual &&
 583        test_cmp expect.log.full actual &&
 584
 585        git log --pretty=raw >actual &&
 586        test_cmp expect.log.raw actual &&
 587
 588        git reflog >actual &&
 589        test_cmp expect.reflog.abbrev actual &&
 590        git reflog --no-abbrev-commit >actual &&
 591        test_cmp expect.reflog.full actual &&
 592
 593        git whatchanged >actual &&
 594        test_cmp expect.whatchanged.abbrev actual &&
 595        git whatchanged --no-abbrev-commit >actual &&
 596        test_cmp expect.whatchanged.full actual
 597'
 598
 599test_expect_success 'show added path under "--follow -M"' '
 600        # This tests for a regression introduced in v1.7.2-rc0~103^2~2
 601        test_create_repo regression &&
 602        (
 603                cd regression &&
 604                test_commit needs-another-commit &&
 605                test_commit foo.bar &&
 606                git log -M --follow -p foo.bar.t &&
 607                git log -M --follow --stat foo.bar.t &&
 608                git log -M --follow --name-only foo.bar.t
 609        )
 610'
 611
 612test_expect_success 'git log -c --follow' '
 613        test_create_repo follow-c &&
 614        (
 615                cd follow-c &&
 616                test_commit initial file original &&
 617                git rm file &&
 618                test_commit rename file2 original &&
 619                git reset --hard initial &&
 620                test_commit modify file foo &&
 621                git merge -m merge rename &&
 622                git log -c --follow file2
 623        )
 624'
 625
 626cat >expect <<\EOF
 627*   commit COMMIT_OBJECT_NAME
 628|\  Merge: MERGE_PARENTS
 629| | Author: A U Thor <author@example.com>
 630| |
 631| |     Merge HEADS DESCRIPTION
 632| |
 633| * commit COMMIT_OBJECT_NAME
 634| | Author: A U Thor <author@example.com>
 635| |
 636| |     reach
 637| | ---
 638| |  reach.t | 1 +
 639| |  1 file changed, 1 insertion(+)
 640| |
 641| | diff --git a/reach.t b/reach.t
 642| | new file mode 100644
 643| | index 0000000..10c9591
 644| | --- /dev/null
 645| | +++ b/reach.t
 646| | @@ -0,0 +1 @@
 647| | +reach
 648| |
 649|  \
 650*-. \   commit COMMIT_OBJECT_NAME
 651|\ \ \  Merge: MERGE_PARENTS
 652| | | | Author: A U Thor <author@example.com>
 653| | | |
 654| | | |     Merge HEADS DESCRIPTION
 655| | | |
 656| | * | commit COMMIT_OBJECT_NAME
 657| | |/  Author: A U Thor <author@example.com>
 658| | |
 659| | |       octopus-b
 660| | |   ---
 661| | |    octopus-b.t | 1 +
 662| | |    1 file changed, 1 insertion(+)
 663| | |
 664| | |   diff --git a/octopus-b.t b/octopus-b.t
 665| | |   new file mode 100644
 666| | |   index 0000000..d5fcad0
 667| | |   --- /dev/null
 668| | |   +++ b/octopus-b.t
 669| | |   @@ -0,0 +1 @@
 670| | |   +octopus-b
 671| | |
 672| * | commit COMMIT_OBJECT_NAME
 673| |/  Author: A U Thor <author@example.com>
 674| |
 675| |       octopus-a
 676| |   ---
 677| |    octopus-a.t | 1 +
 678| |    1 file changed, 1 insertion(+)
 679| |
 680| |   diff --git a/octopus-a.t b/octopus-a.t
 681| |   new file mode 100644
 682| |   index 0000000..11ee015
 683| |   --- /dev/null
 684| |   +++ b/octopus-a.t
 685| |   @@ -0,0 +1 @@
 686| |   +octopus-a
 687| |
 688* | commit COMMIT_OBJECT_NAME
 689|/  Author: A U Thor <author@example.com>
 690|
 691|       seventh
 692|   ---
 693|    seventh.t | 1 +
 694|    1 file changed, 1 insertion(+)
 695|
 696|   diff --git a/seventh.t b/seventh.t
 697|   new file mode 100644
 698|   index 0000000..9744ffc
 699|   --- /dev/null
 700|   +++ b/seventh.t
 701|   @@ -0,0 +1 @@
 702|   +seventh
 703|
 704*   commit COMMIT_OBJECT_NAME
 705|\  Merge: MERGE_PARENTS
 706| | Author: A U Thor <author@example.com>
 707| |
 708| |     Merge branch 'tangle'
 709| |
 710| *   commit COMMIT_OBJECT_NAME
 711| |\  Merge: MERGE_PARENTS
 712| | | Author: A U Thor <author@example.com>
 713| | |
 714| | |     Merge branch 'side' (early part) into tangle
 715| | |
 716| * |   commit COMMIT_OBJECT_NAME
 717| |\ \  Merge: MERGE_PARENTS
 718| | | | Author: A U Thor <author@example.com>
 719| | | |
 720| | | |     Merge branch 'master' (early part) into tangle
 721| | | |
 722| * | | commit COMMIT_OBJECT_NAME
 723| | | | Author: A U Thor <author@example.com>
 724| | | |
 725| | | |     tangle-a
 726| | | | ---
 727| | | |  tangle-a | 1 +
 728| | | |  1 file changed, 1 insertion(+)
 729| | | |
 730| | | | diff --git a/tangle-a b/tangle-a
 731| | | | new file mode 100644
 732| | | | index 0000000..7898192
 733| | | | --- /dev/null
 734| | | | +++ b/tangle-a
 735| | | | @@ -0,0 +1 @@
 736| | | | +a
 737| | | |
 738* | | |   commit COMMIT_OBJECT_NAME
 739|\ \ \ \  Merge: MERGE_PARENTS
 740| | | | | Author: A U Thor <author@example.com>
 741| | | | |
 742| | | | |     Merge branch 'side'
 743| | | | |
 744| * | | | commit COMMIT_OBJECT_NAME
 745| | |_|/  Author: A U Thor <author@example.com>
 746| |/| |
 747| | | |       side-2
 748| | | |   ---
 749| | | |    2 | 1 +
 750| | | |    1 file changed, 1 insertion(+)
 751| | | |
 752| | | |   diff --git a/2 b/2
 753| | | |   new file mode 100644
 754| | | |   index 0000000..0cfbf08
 755| | | |   --- /dev/null
 756| | | |   +++ b/2
 757| | | |   @@ -0,0 +1 @@
 758| | | |   +2
 759| | | |
 760| * | | commit COMMIT_OBJECT_NAME
 761| | | | Author: A U Thor <author@example.com>
 762| | | |
 763| | | |     side-1
 764| | | | ---
 765| | | |  1 | 1 +
 766| | | |  1 file changed, 1 insertion(+)
 767| | | |
 768| | | | diff --git a/1 b/1
 769| | | | new file mode 100644
 770| | | | index 0000000..d00491f
 771| | | | --- /dev/null
 772| | | | +++ b/1
 773| | | | @@ -0,0 +1 @@
 774| | | | +1
 775| | | |
 776* | | | commit COMMIT_OBJECT_NAME
 777| | | | Author: A U Thor <author@example.com>
 778| | | |
 779| | | |     Second
 780| | | | ---
 781| | | |  one | 1 +
 782| | | |  1 file changed, 1 insertion(+)
 783| | | |
 784| | | | diff --git a/one b/one
 785| | | | new file mode 100644
 786| | | | index 0000000..9a33383
 787| | | | --- /dev/null
 788| | | | +++ b/one
 789| | | | @@ -0,0 +1 @@
 790| | | | +case
 791| | | |
 792* | | | commit COMMIT_OBJECT_NAME
 793| |_|/  Author: A U Thor <author@example.com>
 794|/| |
 795| | |       sixth
 796| | |   ---
 797| | |    a/two | 1 -
 798| | |    1 file changed, 1 deletion(-)
 799| | |
 800| | |   diff --git a/a/two b/a/two
 801| | |   deleted file mode 100644
 802| | |   index 9245af5..0000000
 803| | |   --- a/a/two
 804| | |   +++ /dev/null
 805| | |   @@ -1 +0,0 @@
 806| | |   -ni
 807| | |
 808* | | commit COMMIT_OBJECT_NAME
 809| | | Author: A U Thor <author@example.com>
 810| | |
 811| | |     fifth
 812| | | ---
 813| | |  a/two | 1 +
 814| | |  1 file changed, 1 insertion(+)
 815| | |
 816| | | diff --git a/a/two b/a/two
 817| | | new file mode 100644
 818| | | index 0000000..9245af5
 819| | | --- /dev/null
 820| | | +++ b/a/two
 821| | | @@ -0,0 +1 @@
 822| | | +ni
 823| | |
 824* | | commit COMMIT_OBJECT_NAME
 825|/ /  Author: A U Thor <author@example.com>
 826| |
 827| |       fourth
 828| |   ---
 829| |    ein | 1 +
 830| |    1 file changed, 1 insertion(+)
 831| |
 832| |   diff --git a/ein b/ein
 833| |   new file mode 100644
 834| |   index 0000000..9d7e69f
 835| |   --- /dev/null
 836| |   +++ b/ein
 837| |   @@ -0,0 +1 @@
 838| |   +ichi
 839| |
 840* | commit COMMIT_OBJECT_NAME
 841|/  Author: A U Thor <author@example.com>
 842|
 843|       third
 844|   ---
 845|    ichi | 1 +
 846|    one  | 1 -
 847|    2 files changed, 1 insertion(+), 1 deletion(-)
 848|
 849|   diff --git a/ichi b/ichi
 850|   new file mode 100644
 851|   index 0000000..9d7e69f
 852|   --- /dev/null
 853|   +++ b/ichi
 854|   @@ -0,0 +1 @@
 855|   +ichi
 856|   diff --git a/one b/one
 857|   deleted file mode 100644
 858|   index 9d7e69f..0000000
 859|   --- a/one
 860|   +++ /dev/null
 861|   @@ -1 +0,0 @@
 862|   -ichi
 863|
 864* commit COMMIT_OBJECT_NAME
 865| Author: A U Thor <author@example.com>
 866|
 867|     second
 868| ---
 869|  one | 2 +-
 870|  1 file changed, 1 insertion(+), 1 deletion(-)
 871|
 872| diff --git a/one b/one
 873| index 5626abf..9d7e69f 100644
 874| --- a/one
 875| +++ b/one
 876| @@ -1 +1 @@
 877| -one
 878| +ichi
 879|
 880* commit COMMIT_OBJECT_NAME
 881  Author: A U Thor <author@example.com>
 882
 883      initial
 884  ---
 885   one | 1 +
 886   1 file changed, 1 insertion(+)
 887
 888  diff --git a/one b/one
 889  new file mode 100644
 890  index 0000000..5626abf
 891  --- /dev/null
 892  +++ b/one
 893  @@ -0,0 +1 @@
 894  +one
 895EOF
 896
 897sanitize_output () {
 898        sed -e 's/ *$//' \
 899            -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
 900            -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
 901            -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
 902            -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
 903            -e 's/, 0 deletions(-)//' \
 904            -e 's/, 0 insertions(+)//' \
 905            -e 's/ 1 files changed, / 1 file changed, /' \
 906            -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
 907            -e 's/, 1 insertions(+)/, 1 insertion(+)/'
 908}
 909
 910test_expect_success 'log --graph with diff and stats' '
 911        git log --no-renames --graph --pretty=short --stat -p >actual &&
 912        sanitize_output >actual.sanitized <actual &&
 913        test_i18ncmp expect actual.sanitized
 914'
 915
 916cat >expect <<\EOF
 917*** *   commit COMMIT_OBJECT_NAME
 918*** |\  Merge: MERGE_PARENTS
 919*** | | Author: A U Thor <author@example.com>
 920*** | |
 921*** | |     Merge HEADS DESCRIPTION
 922*** | |
 923*** | * commit COMMIT_OBJECT_NAME
 924*** | | Author: A U Thor <author@example.com>
 925*** | |
 926*** | |     reach
 927*** | | ---
 928*** | |  reach.t | 1 +
 929*** | |  1 file changed, 1 insertion(+)
 930*** | |
 931*** | | diff --git a/reach.t b/reach.t
 932*** | | new file mode 100644
 933*** | | index 0000000..10c9591
 934*** | | --- /dev/null
 935*** | | +++ b/reach.t
 936*** | | @@ -0,0 +1 @@
 937*** | | +reach
 938*** | |
 939*** |  \
 940*** *-. \   commit COMMIT_OBJECT_NAME
 941*** |\ \ \  Merge: MERGE_PARENTS
 942*** | | | | Author: A U Thor <author@example.com>
 943*** | | | |
 944*** | | | |     Merge HEADS DESCRIPTION
 945*** | | | |
 946*** | | * | commit COMMIT_OBJECT_NAME
 947*** | | |/  Author: A U Thor <author@example.com>
 948*** | | |
 949*** | | |       octopus-b
 950*** | | |   ---
 951*** | | |    octopus-b.t | 1 +
 952*** | | |    1 file changed, 1 insertion(+)
 953*** | | |
 954*** | | |   diff --git a/octopus-b.t b/octopus-b.t
 955*** | | |   new file mode 100644
 956*** | | |   index 0000000..d5fcad0
 957*** | | |   --- /dev/null
 958*** | | |   +++ b/octopus-b.t
 959*** | | |   @@ -0,0 +1 @@
 960*** | | |   +octopus-b
 961*** | | |
 962*** | * | commit COMMIT_OBJECT_NAME
 963*** | |/  Author: A U Thor <author@example.com>
 964*** | |
 965*** | |       octopus-a
 966*** | |   ---
 967*** | |    octopus-a.t | 1 +
 968*** | |    1 file changed, 1 insertion(+)
 969*** | |
 970*** | |   diff --git a/octopus-a.t b/octopus-a.t
 971*** | |   new file mode 100644
 972*** | |   index 0000000..11ee015
 973*** | |   --- /dev/null
 974*** | |   +++ b/octopus-a.t
 975*** | |   @@ -0,0 +1 @@
 976*** | |   +octopus-a
 977*** | |
 978*** * | commit COMMIT_OBJECT_NAME
 979*** |/  Author: A U Thor <author@example.com>
 980*** |
 981*** |       seventh
 982*** |   ---
 983*** |    seventh.t | 1 +
 984*** |    1 file changed, 1 insertion(+)
 985*** |
 986*** |   diff --git a/seventh.t b/seventh.t
 987*** |   new file mode 100644
 988*** |   index 0000000..9744ffc
 989*** |   --- /dev/null
 990*** |   +++ b/seventh.t
 991*** |   @@ -0,0 +1 @@
 992*** |   +seventh
 993*** |
 994*** *   commit COMMIT_OBJECT_NAME
 995*** |\  Merge: MERGE_PARENTS
 996*** | | Author: A U Thor <author@example.com>
 997*** | |
 998*** | |     Merge branch 'tangle'
 999*** | |
1000*** | *   commit COMMIT_OBJECT_NAME
1001*** | |\  Merge: MERGE_PARENTS
1002*** | | | Author: A U Thor <author@example.com>
1003*** | | |
1004*** | | |     Merge branch 'side' (early part) into tangle
1005*** | | |
1006*** | * |   commit COMMIT_OBJECT_NAME
1007*** | |\ \  Merge: MERGE_PARENTS
1008*** | | | | Author: A U Thor <author@example.com>
1009*** | | | |
1010*** | | | |     Merge branch 'master' (early part) into tangle
1011*** | | | |
1012*** | * | | commit COMMIT_OBJECT_NAME
1013*** | | | | Author: A U Thor <author@example.com>
1014*** | | | |
1015*** | | | |     tangle-a
1016*** | | | | ---
1017*** | | | |  tangle-a | 1 +
1018*** | | | |  1 file changed, 1 insertion(+)
1019*** | | | |
1020*** | | | | diff --git a/tangle-a b/tangle-a
1021*** | | | | new file mode 100644
1022*** | | | | index 0000000..7898192
1023*** | | | | --- /dev/null
1024*** | | | | +++ b/tangle-a
1025*** | | | | @@ -0,0 +1 @@
1026*** | | | | +a
1027*** | | | |
1028*** * | | |   commit COMMIT_OBJECT_NAME
1029*** |\ \ \ \  Merge: MERGE_PARENTS
1030*** | | | | | Author: A U Thor <author@example.com>
1031*** | | | | |
1032*** | | | | |     Merge branch 'side'
1033*** | | | | |
1034*** | * | | | commit COMMIT_OBJECT_NAME
1035*** | | |_|/  Author: A U Thor <author@example.com>
1036*** | |/| |
1037*** | | | |       side-2
1038*** | | | |   ---
1039*** | | | |    2 | 1 +
1040*** | | | |    1 file changed, 1 insertion(+)
1041*** | | | |
1042*** | | | |   diff --git a/2 b/2
1043*** | | | |   new file mode 100644
1044*** | | | |   index 0000000..0cfbf08
1045*** | | | |   --- /dev/null
1046*** | | | |   +++ b/2
1047*** | | | |   @@ -0,0 +1 @@
1048*** | | | |   +2
1049*** | | | |
1050*** | * | | commit COMMIT_OBJECT_NAME
1051*** | | | | Author: A U Thor <author@example.com>
1052*** | | | |
1053*** | | | |     side-1
1054*** | | | | ---
1055*** | | | |  1 | 1 +
1056*** | | | |  1 file changed, 1 insertion(+)
1057*** | | | |
1058*** | | | | diff --git a/1 b/1
1059*** | | | | new file mode 100644
1060*** | | | | index 0000000..d00491f
1061*** | | | | --- /dev/null
1062*** | | | | +++ b/1
1063*** | | | | @@ -0,0 +1 @@
1064*** | | | | +1
1065*** | | | |
1066*** * | | | commit COMMIT_OBJECT_NAME
1067*** | | | | Author: A U Thor <author@example.com>
1068*** | | | |
1069*** | | | |     Second
1070*** | | | | ---
1071*** | | | |  one | 1 +
1072*** | | | |  1 file changed, 1 insertion(+)
1073*** | | | |
1074*** | | | | diff --git a/one b/one
1075*** | | | | new file mode 100644
1076*** | | | | index 0000000..9a33383
1077*** | | | | --- /dev/null
1078*** | | | | +++ b/one
1079*** | | | | @@ -0,0 +1 @@
1080*** | | | | +case
1081*** | | | |
1082*** * | | | commit COMMIT_OBJECT_NAME
1083*** | |_|/  Author: A U Thor <author@example.com>
1084*** |/| |
1085*** | | |       sixth
1086*** | | |   ---
1087*** | | |    a/two | 1 -
1088*** | | |    1 file changed, 1 deletion(-)
1089*** | | |
1090*** | | |   diff --git a/a/two b/a/two
1091*** | | |   deleted file mode 100644
1092*** | | |   index 9245af5..0000000
1093*** | | |   --- a/a/two
1094*** | | |   +++ /dev/null
1095*** | | |   @@ -1 +0,0 @@
1096*** | | |   -ni
1097*** | | |
1098*** * | | commit COMMIT_OBJECT_NAME
1099*** | | | Author: A U Thor <author@example.com>
1100*** | | |
1101*** | | |     fifth
1102*** | | | ---
1103*** | | |  a/two | 1 +
1104*** | | |  1 file changed, 1 insertion(+)
1105*** | | |
1106*** | | | diff --git a/a/two b/a/two
1107*** | | | new file mode 100644
1108*** | | | index 0000000..9245af5
1109*** | | | --- /dev/null
1110*** | | | +++ b/a/two
1111*** | | | @@ -0,0 +1 @@
1112*** | | | +ni
1113*** | | |
1114*** * | | commit COMMIT_OBJECT_NAME
1115*** |/ /  Author: A U Thor <author@example.com>
1116*** | |
1117*** | |       fourth
1118*** | |   ---
1119*** | |    ein | 1 +
1120*** | |    1 file changed, 1 insertion(+)
1121*** | |
1122*** | |   diff --git a/ein b/ein
1123*** | |   new file mode 100644
1124*** | |   index 0000000..9d7e69f
1125*** | |   --- /dev/null
1126*** | |   +++ b/ein
1127*** | |   @@ -0,0 +1 @@
1128*** | |   +ichi
1129*** | |
1130*** * | commit COMMIT_OBJECT_NAME
1131*** |/  Author: A U Thor <author@example.com>
1132*** |
1133*** |       third
1134*** |   ---
1135*** |    ichi | 1 +
1136*** |    one  | 1 -
1137*** |    2 files changed, 1 insertion(+), 1 deletion(-)
1138*** |
1139*** |   diff --git a/ichi b/ichi
1140*** |   new file mode 100644
1141*** |   index 0000000..9d7e69f
1142*** |   --- /dev/null
1143*** |   +++ b/ichi
1144*** |   @@ -0,0 +1 @@
1145*** |   +ichi
1146*** |   diff --git a/one b/one
1147*** |   deleted file mode 100644
1148*** |   index 9d7e69f..0000000
1149*** |   --- a/one
1150*** |   +++ /dev/null
1151*** |   @@ -1 +0,0 @@
1152*** |   -ichi
1153*** |
1154*** * commit COMMIT_OBJECT_NAME
1155*** | Author: A U Thor <author@example.com>
1156*** |
1157*** |     second
1158*** | ---
1159*** |  one | 2 +-
1160*** |  1 file changed, 1 insertion(+), 1 deletion(-)
1161*** |
1162*** | diff --git a/one b/one
1163*** | index 5626abf..9d7e69f 100644
1164*** | --- a/one
1165*** | +++ b/one
1166*** | @@ -1 +1 @@
1167*** | -one
1168*** | +ichi
1169*** |
1170*** * commit COMMIT_OBJECT_NAME
1171***   Author: A U Thor <author@example.com>
1172***
1173***       initial
1174***   ---
1175***    one | 1 +
1176***    1 file changed, 1 insertion(+)
1177***
1178***   diff --git a/one b/one
1179***   new file mode 100644
1180***   index 0000000..5626abf
1181***   --- /dev/null
1182***   +++ b/one
1183***   @@ -0,0 +1 @@
1184***   +one
1185EOF
1186
1187test_expect_success 'log --line-prefix="*** " --graph with diff and stats' '
1188        git log --line-prefix="*** " --no-renames --graph --pretty=short --stat -p >actual &&
1189        sanitize_output >actual.sanitized <actual &&
1190        test_i18ncmp expect actual.sanitized
1191'
1192
1193test_expect_success 'dotdot is a parent directory' '
1194        mkdir -p a/b &&
1195        ( echo sixth && echo fifth ) >expect &&
1196        ( cd a/b && git log --format=%s .. ) >actual &&
1197        test_cmp expect actual
1198'
1199
1200test_expect_success GPG 'setup signed branch' '
1201        test_when_finished "git reset --hard && git checkout master" &&
1202        git checkout -b signed master &&
1203        echo foo >foo &&
1204        git add foo &&
1205        git commit -S -m signed_commit
1206'
1207
1208test_expect_success GPG 'log --graph --show-signature' '
1209        git log --graph --show-signature -n1 signed >actual &&
1210        grep "^| gpg: Signature made" actual &&
1211        grep "^| gpg: Good signature" actual
1212'
1213
1214test_expect_success GPG 'log --graph --show-signature for merged tag' '
1215        test_when_finished "git reset --hard && git checkout master" &&
1216        git checkout -b plain master &&
1217        echo aaa >bar &&
1218        git add bar &&
1219        git commit -m bar_commit &&
1220        git checkout -b tagged master &&
1221        echo bbb >baz &&
1222        git add baz &&
1223        git commit -m baz_commit &&
1224        git tag -s -m signed_tag_msg signed_tag &&
1225        git checkout plain &&
1226        git merge --no-ff -m msg signed_tag &&
1227        git log --graph --show-signature -n1 plain >actual &&
1228        grep "^|\\\  merged tag" actual &&
1229        grep "^| | gpg: Signature made" actual &&
1230        grep "^| | gpg: Good signature" actual
1231'
1232
1233test_expect_success GPG '--no-show-signature overrides --show-signature' '
1234        git log -1 --show-signature --no-show-signature signed >actual &&
1235        ! grep "^gpg:" actual
1236'
1237
1238test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
1239        test_config log.showsignature true &&
1240        git log -1 signed >actual &&
1241        grep "gpg: Signature made" actual &&
1242        grep "gpg: Good signature" actual
1243'
1244
1245test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
1246        test_config log.showsignature true &&
1247        git log -1 --no-show-signature signed >actual &&
1248        ! grep "^gpg:" actual
1249'
1250
1251test_expect_success GPG '--show-signature overrides log.showsignature=false' '
1252        test_config log.showsignature false &&
1253        git log -1 --show-signature signed >actual &&
1254        grep "gpg: Signature made" actual &&
1255        grep "gpg: Good signature" actual
1256'
1257
1258test_expect_success 'log --graph --no-walk is forbidden' '
1259        test_must_fail git log --graph --no-walk
1260'
1261
1262test_expect_success 'log diagnoses bogus HEAD' '
1263        git init empty &&
1264        test_must_fail git -C empty log 2>stderr &&
1265        test_i18ngrep does.not.have.any.commits stderr &&
1266        echo 1234abcd >empty/.git/refs/heads/master &&
1267        test_must_fail git -C empty log 2>stderr &&
1268        test_i18ngrep broken stderr &&
1269        echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
1270        test_must_fail git -C empty log 2>stderr &&
1271        test_i18ngrep broken stderr &&
1272        test_must_fail git -C empty log --default totally-bogus 2>stderr &&
1273        test_i18ngrep broken stderr
1274'
1275
1276test_expect_success 'set up --source tests' '
1277        git checkout --orphan source-a &&
1278        test_commit one &&
1279        test_commit two &&
1280        git checkout -b source-b HEAD^ &&
1281        test_commit three
1282'
1283
1284test_expect_success 'log --source paints branch names' '
1285        cat >expect <<-\EOF &&
1286        09e12a9 source-b three
1287        8e393e1 source-a two
1288        1ac6c77 source-b one
1289        EOF
1290        git log --oneline --source source-a source-b >actual &&
1291        test_cmp expect actual
1292'
1293
1294test_expect_success 'log --source paints tag names' '
1295        git tag -m tagged source-tag &&
1296        cat >expect <<-\EOF &&
1297        09e12a9 source-tag three
1298        8e393e1 source-a two
1299        1ac6c77 source-tag one
1300        EOF
1301        git log --oneline --source source-tag source-a >actual &&
1302        test_cmp expect actual
1303'
1304
1305test_done