t / t4202-log.shon commit Merge branch 'jk/ident-ai-canonname-could-be-null' into maint (11738dd)
   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
 1915d31159 fourth
 192804a787 sixth
 193394ef78 fifth
 194EOF
 195test_expect_success 'git log --no-walk=unsorted <commits> leaves list of commits as given' '
 196        git log --no-walk=unsorted --oneline 5d31159 804a787 394ef78 > actual &&
 197        test_cmp expect actual
 198'
 199
 200test_expect_success 'git show <commits> leaves list of commits as given' '
 201        git show --oneline -s 5d31159 804a787 394ef78 > actual &&
 202        test_cmp expect actual
 203'
 204
 205test_expect_success 'setup case sensitivity tests' '
 206        echo case >one &&
 207        test_tick &&
 208        git add one &&
 209        git commit -a -m Second
 210'
 211
 212test_expect_success 'log --grep' '
 213        echo second >expect &&
 214        git log -1 --pretty="tformat:%s" --grep=sec >actual &&
 215        test_cmp expect actual
 216'
 217
 218cat > expect << EOF
 219second
 220initial
 221EOF
 222test_expect_success 'log --invert-grep --grep' '
 223        git log --pretty="tformat:%s" --invert-grep --grep=th --grep=Sec >actual &&
 224        test_cmp expect actual
 225'
 226
 227test_expect_success 'log --invert-grep --grep -i' '
 228        echo initial >expect &&
 229        git log --pretty="tformat:%s" --invert-grep -i --grep=th --grep=Sec >actual &&
 230        test_cmp expect actual
 231'
 232
 233test_expect_success 'log --grep option parsing' '
 234        echo second >expect &&
 235        git log -1 --pretty="tformat:%s" --grep sec >actual &&
 236        test_cmp expect actual &&
 237        test_must_fail git log -1 --pretty="tformat:%s" --grep
 238'
 239
 240test_expect_success 'log -i --grep' '
 241        echo Second >expect &&
 242        git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
 243        test_cmp expect actual
 244'
 245
 246test_expect_success 'log --grep -i' '
 247        echo Second >expect &&
 248        git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
 249        test_cmp expect actual
 250'
 251
 252test_expect_success 'log -F -E --grep=<ere> uses ere' '
 253        echo second >expect &&
 254        git log -1 --pretty="tformat:%s" -F -E --grep=s.c.nd >actual &&
 255        test_cmp expect actual
 256'
 257
 258test_expect_success 'log with grep.patternType configuration' '
 259        >expect &&
 260        git -c grep.patterntype=fixed \
 261        log -1 --pretty=tformat:%s --grep=s.c.nd >actual &&
 262        test_cmp expect actual
 263'
 264
 265test_expect_success 'log with grep.patternType configuration and command line' '
 266        echo second >expect &&
 267        git -c grep.patterntype=fixed \
 268        log -1 --pretty=tformat:%s --basic-regexp --grep=s.c.nd >actual &&
 269        test_cmp expect actual
 270'
 271
 272cat > expect <<EOF
 273* Second
 274* sixth
 275* fifth
 276* fourth
 277* third
 278* second
 279* initial
 280EOF
 281
 282test_expect_success 'simple log --graph' '
 283        git log --graph --pretty=tformat:%s >actual &&
 284        test_cmp expect actual
 285'
 286
 287test_expect_success 'set up merge history' '
 288        git checkout -b side HEAD~4 &&
 289        test_commit side-1 1 1 &&
 290        test_commit side-2 2 2 &&
 291        git checkout master &&
 292        git merge side
 293'
 294
 295cat > expect <<\EOF
 296*   Merge branch 'side'
 297|\
 298| * side-2
 299| * side-1
 300* | Second
 301* | sixth
 302* | fifth
 303* | fourth
 304|/
 305* third
 306* second
 307* initial
 308EOF
 309
 310test_expect_success 'log --graph with merge' '
 311        git log --graph --date-order --pretty=tformat:%s |
 312                sed "s/ *\$//" >actual &&
 313        test_cmp expect actual
 314'
 315
 316test_expect_success 'log --raw --graph -m with merge' '
 317        git log --raw --graph --oneline -m master | head -n 500 >actual &&
 318        grep "initial" actual
 319'
 320
 321test_expect_success 'diff-tree --graph' '
 322        git diff-tree --graph master^ | head -n 500 >actual &&
 323        grep "one" actual
 324'
 325
 326cat > expect <<\EOF
 327*   commit master
 328|\  Merge: A B
 329| | Author: A U Thor <author@example.com>
 330| |
 331| |     Merge branch 'side'
 332| |
 333| * commit side
 334| | Author: A U Thor <author@example.com>
 335| |
 336| |     side-2
 337| |
 338| * commit tags/side-1
 339| | Author: A U Thor <author@example.com>
 340| |
 341| |     side-1
 342| |
 343* | commit master~1
 344| | Author: A U Thor <author@example.com>
 345| |
 346| |     Second
 347| |
 348* | commit master~2
 349| | Author: A U Thor <author@example.com>
 350| |
 351| |     sixth
 352| |
 353* | commit master~3
 354| | Author: A U Thor <author@example.com>
 355| |
 356| |     fifth
 357| |
 358* | commit master~4
 359|/  Author: A U Thor <author@example.com>
 360|
 361|       fourth
 362|
 363* commit tags/side-1~1
 364| Author: A U Thor <author@example.com>
 365|
 366|     third
 367|
 368* commit tags/side-1~2
 369| Author: A U Thor <author@example.com>
 370|
 371|     second
 372|
 373* commit tags/side-1~3
 374  Author: A U Thor <author@example.com>
 375
 376      initial
 377EOF
 378
 379test_expect_success 'log --graph with full output' '
 380        git log --graph --date-order --pretty=short |
 381                git name-rev --name-only --stdin |
 382                sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual &&
 383        test_cmp expect actual
 384'
 385
 386test_expect_success 'set up more tangled history' '
 387        git checkout -b tangle HEAD~6 &&
 388        test_commit tangle-a tangle-a a &&
 389        git merge master~3 &&
 390        git merge side~1 &&
 391        git checkout master &&
 392        git merge tangle &&
 393        git checkout -b reach &&
 394        test_commit reach &&
 395        git checkout master &&
 396        git checkout -b octopus-a &&
 397        test_commit octopus-a &&
 398        git checkout master &&
 399        git checkout -b octopus-b &&
 400        test_commit octopus-b &&
 401        git checkout master &&
 402        test_commit seventh &&
 403        git merge octopus-a octopus-b &&
 404        git merge reach
 405'
 406
 407cat > expect <<\EOF
 408*   Merge tag 'reach'
 409|\
 410| \
 411|  \
 412*-. \   Merge tags 'octopus-a' and 'octopus-b'
 413|\ \ \
 414* | | | seventh
 415| | * | octopus-b
 416| |/ /
 417|/| |
 418| * | octopus-a
 419|/ /
 420| * reach
 421|/
 422*   Merge branch 'tangle'
 423|\
 424| *   Merge branch 'side' (early part) into tangle
 425| |\
 426| * \   Merge branch 'master' (early part) into tangle
 427| |\ \
 428| * | | tangle-a
 429* | | |   Merge branch 'side'
 430|\ \ \ \
 431| * | | | side-2
 432| | |_|/
 433| |/| |
 434| * | | side-1
 435* | | | Second
 436* | | | sixth
 437| |_|/
 438|/| |
 439* | | fifth
 440* | | fourth
 441|/ /
 442* | third
 443|/
 444* second
 445* initial
 446EOF
 447
 448test_expect_success 'log --graph with merge' '
 449        git log --graph --date-order --pretty=tformat:%s |
 450                sed "s/ *\$//" >actual &&
 451        test_cmp expect actual
 452'
 453
 454test_expect_success 'log.decorate configuration' '
 455        git log --oneline >expect.none &&
 456        git log --oneline --decorate >expect.short &&
 457        git log --oneline --decorate=full >expect.full &&
 458
 459        echo "[log] decorate" >>.git/config &&
 460        git log --oneline >actual &&
 461        test_cmp expect.short actual &&
 462
 463        test_config log.decorate true &&
 464        git log --oneline >actual &&
 465        test_cmp expect.short actual &&
 466        git log --oneline --decorate=full >actual &&
 467        test_cmp expect.full actual &&
 468        git log --oneline --decorate=no >actual &&
 469        test_cmp expect.none actual &&
 470
 471        test_config log.decorate no &&
 472        git log --oneline >actual &&
 473        test_cmp expect.none actual &&
 474        git log --oneline --decorate >actual &&
 475        test_cmp expect.short actual &&
 476        git log --oneline --decorate=full >actual &&
 477        test_cmp expect.full actual &&
 478
 479        test_config log.decorate 1 &&
 480        git log --oneline >actual &&
 481        test_cmp expect.short actual &&
 482        git log --oneline --decorate=full >actual &&
 483        test_cmp expect.full actual &&
 484        git log --oneline --decorate=no >actual &&
 485        test_cmp expect.none actual &&
 486
 487        test_config log.decorate short &&
 488        git log --oneline >actual &&
 489        test_cmp expect.short actual &&
 490        git log --oneline --no-decorate >actual &&
 491        test_cmp expect.none actual &&
 492        git log --oneline --decorate=full >actual &&
 493        test_cmp expect.full actual &&
 494
 495        test_config log.decorate full &&
 496        git log --oneline >actual &&
 497        test_cmp expect.full actual &&
 498        git log --oneline --no-decorate >actual &&
 499        test_cmp expect.none actual &&
 500        git log --oneline --decorate >actual &&
 501        test_cmp expect.short actual &&
 502
 503        test_unconfig log.decorate &&
 504        git log --pretty=raw >expect.raw &&
 505        test_config log.decorate full &&
 506        git log --pretty=raw >actual &&
 507        test_cmp expect.raw actual
 508
 509'
 510
 511test_expect_success 'reflog is expected format' '
 512        git log -g --abbrev-commit --pretty=oneline >expect &&
 513        git reflog >actual &&
 514        test_cmp expect actual
 515'
 516
 517test_expect_success 'whatchanged is expected format' '
 518        git log --no-merges --raw >expect &&
 519        git whatchanged >actual &&
 520        test_cmp expect actual
 521'
 522
 523test_expect_success 'log.abbrevCommit configuration' '
 524        git log --abbrev-commit >expect.log.abbrev &&
 525        git log --no-abbrev-commit >expect.log.full &&
 526        git log --pretty=raw >expect.log.raw &&
 527        git reflog --abbrev-commit >expect.reflog.abbrev &&
 528        git reflog --no-abbrev-commit >expect.reflog.full &&
 529        git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
 530        git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
 531
 532        test_config log.abbrevCommit true &&
 533
 534        git log >actual &&
 535        test_cmp expect.log.abbrev actual &&
 536        git log --no-abbrev-commit >actual &&
 537        test_cmp expect.log.full actual &&
 538
 539        git log --pretty=raw >actual &&
 540        test_cmp expect.log.raw actual &&
 541
 542        git reflog >actual &&
 543        test_cmp expect.reflog.abbrev actual &&
 544        git reflog --no-abbrev-commit >actual &&
 545        test_cmp expect.reflog.full actual &&
 546
 547        git whatchanged >actual &&
 548        test_cmp expect.whatchanged.abbrev actual &&
 549        git whatchanged --no-abbrev-commit >actual &&
 550        test_cmp expect.whatchanged.full actual
 551'
 552
 553test_expect_success 'show added path under "--follow -M"' '
 554        # This tests for a regression introduced in v1.7.2-rc0~103^2~2
 555        test_create_repo regression &&
 556        (
 557                cd regression &&
 558                test_commit needs-another-commit &&
 559                test_commit foo.bar &&
 560                git log -M --follow -p foo.bar.t &&
 561                git log -M --follow --stat foo.bar.t &&
 562                git log -M --follow --name-only foo.bar.t
 563        )
 564'
 565
 566test_expect_success 'git log -c --follow' '
 567        test_create_repo follow-c &&
 568        (
 569                cd follow-c &&
 570                test_commit initial file original &&
 571                git rm file &&
 572                test_commit rename file2 original &&
 573                git reset --hard initial &&
 574                test_commit modify file foo &&
 575                git merge -m merge rename &&
 576                git log -c --follow file2
 577        )
 578'
 579
 580cat >expect <<\EOF
 581*   commit COMMIT_OBJECT_NAME
 582|\  Merge: MERGE_PARENTS
 583| | Author: A U Thor <author@example.com>
 584| |
 585| |     Merge HEADS DESCRIPTION
 586| |
 587| * commit COMMIT_OBJECT_NAME
 588| | Author: A U Thor <author@example.com>
 589| |
 590| |     reach
 591| | ---
 592| |  reach.t | 1 +
 593| |  1 file changed, 1 insertion(+)
 594| |
 595| | diff --git a/reach.t b/reach.t
 596| | new file mode 100644
 597| | index 0000000..10c9591
 598| | --- /dev/null
 599| | +++ b/reach.t
 600| | @@ -0,0 +1 @@
 601| | +reach
 602| |
 603|  \
 604*-. \   commit COMMIT_OBJECT_NAME
 605|\ \ \  Merge: MERGE_PARENTS
 606| | | | Author: A U Thor <author@example.com>
 607| | | |
 608| | | |     Merge HEADS DESCRIPTION
 609| | | |
 610| | * | commit COMMIT_OBJECT_NAME
 611| | |/  Author: A U Thor <author@example.com>
 612| | |
 613| | |       octopus-b
 614| | |   ---
 615| | |    octopus-b.t | 1 +
 616| | |    1 file changed, 1 insertion(+)
 617| | |
 618| | |   diff --git a/octopus-b.t b/octopus-b.t
 619| | |   new file mode 100644
 620| | |   index 0000000..d5fcad0
 621| | |   --- /dev/null
 622| | |   +++ b/octopus-b.t
 623| | |   @@ -0,0 +1 @@
 624| | |   +octopus-b
 625| | |
 626| * | commit COMMIT_OBJECT_NAME
 627| |/  Author: A U Thor <author@example.com>
 628| |
 629| |       octopus-a
 630| |   ---
 631| |    octopus-a.t | 1 +
 632| |    1 file changed, 1 insertion(+)
 633| |
 634| |   diff --git a/octopus-a.t b/octopus-a.t
 635| |   new file mode 100644
 636| |   index 0000000..11ee015
 637| |   --- /dev/null
 638| |   +++ b/octopus-a.t
 639| |   @@ -0,0 +1 @@
 640| |   +octopus-a
 641| |
 642* | commit COMMIT_OBJECT_NAME
 643|/  Author: A U Thor <author@example.com>
 644|
 645|       seventh
 646|   ---
 647|    seventh.t | 1 +
 648|    1 file changed, 1 insertion(+)
 649|
 650|   diff --git a/seventh.t b/seventh.t
 651|   new file mode 100644
 652|   index 0000000..9744ffc
 653|   --- /dev/null
 654|   +++ b/seventh.t
 655|   @@ -0,0 +1 @@
 656|   +seventh
 657|
 658*   commit COMMIT_OBJECT_NAME
 659|\  Merge: MERGE_PARENTS
 660| | Author: A U Thor <author@example.com>
 661| |
 662| |     Merge branch 'tangle'
 663| |
 664| *   commit COMMIT_OBJECT_NAME
 665| |\  Merge: MERGE_PARENTS
 666| | | Author: A U Thor <author@example.com>
 667| | |
 668| | |     Merge branch 'side' (early part) into tangle
 669| | |
 670| * |   commit COMMIT_OBJECT_NAME
 671| |\ \  Merge: MERGE_PARENTS
 672| | | | Author: A U Thor <author@example.com>
 673| | | |
 674| | | |     Merge branch 'master' (early part) into tangle
 675| | | |
 676| * | | commit COMMIT_OBJECT_NAME
 677| | | | Author: A U Thor <author@example.com>
 678| | | |
 679| | | |     tangle-a
 680| | | | ---
 681| | | |  tangle-a | 1 +
 682| | | |  1 file changed, 1 insertion(+)
 683| | | |
 684| | | | diff --git a/tangle-a b/tangle-a
 685| | | | new file mode 100644
 686| | | | index 0000000..7898192
 687| | | | --- /dev/null
 688| | | | +++ b/tangle-a
 689| | | | @@ -0,0 +1 @@
 690| | | | +a
 691| | | |
 692* | | |   commit COMMIT_OBJECT_NAME
 693|\ \ \ \  Merge: MERGE_PARENTS
 694| | | | | Author: A U Thor <author@example.com>
 695| | | | |
 696| | | | |     Merge branch 'side'
 697| | | | |
 698| * | | | commit COMMIT_OBJECT_NAME
 699| | |_|/  Author: A U Thor <author@example.com>
 700| |/| |
 701| | | |       side-2
 702| | | |   ---
 703| | | |    2 | 1 +
 704| | | |    1 file changed, 1 insertion(+)
 705| | | |
 706| | | |   diff --git a/2 b/2
 707| | | |   new file mode 100644
 708| | | |   index 0000000..0cfbf08
 709| | | |   --- /dev/null
 710| | | |   +++ b/2
 711| | | |   @@ -0,0 +1 @@
 712| | | |   +2
 713| | | |
 714| * | | commit COMMIT_OBJECT_NAME
 715| | | | Author: A U Thor <author@example.com>
 716| | | |
 717| | | |     side-1
 718| | | | ---
 719| | | |  1 | 1 +
 720| | | |  1 file changed, 1 insertion(+)
 721| | | |
 722| | | | diff --git a/1 b/1
 723| | | | new file mode 100644
 724| | | | index 0000000..d00491f
 725| | | | --- /dev/null
 726| | | | +++ b/1
 727| | | | @@ -0,0 +1 @@
 728| | | | +1
 729| | | |
 730* | | | commit COMMIT_OBJECT_NAME
 731| | | | Author: A U Thor <author@example.com>
 732| | | |
 733| | | |     Second
 734| | | | ---
 735| | | |  one | 1 +
 736| | | |  1 file changed, 1 insertion(+)
 737| | | |
 738| | | | diff --git a/one b/one
 739| | | | new file mode 100644
 740| | | | index 0000000..9a33383
 741| | | | --- /dev/null
 742| | | | +++ b/one
 743| | | | @@ -0,0 +1 @@
 744| | | | +case
 745| | | |
 746* | | | commit COMMIT_OBJECT_NAME
 747| |_|/  Author: A U Thor <author@example.com>
 748|/| |
 749| | |       sixth
 750| | |   ---
 751| | |    a/two | 1 -
 752| | |    1 file changed, 1 deletion(-)
 753| | |
 754| | |   diff --git a/a/two b/a/two
 755| | |   deleted file mode 100644
 756| | |   index 9245af5..0000000
 757| | |   --- a/a/two
 758| | |   +++ /dev/null
 759| | |   @@ -1 +0,0 @@
 760| | |   -ni
 761| | |
 762* | | commit COMMIT_OBJECT_NAME
 763| | | Author: A U Thor <author@example.com>
 764| | |
 765| | |     fifth
 766| | | ---
 767| | |  a/two | 1 +
 768| | |  1 file changed, 1 insertion(+)
 769| | |
 770| | | diff --git a/a/two b/a/two
 771| | | new file mode 100644
 772| | | index 0000000..9245af5
 773| | | --- /dev/null
 774| | | +++ b/a/two
 775| | | @@ -0,0 +1 @@
 776| | | +ni
 777| | |
 778* | | commit COMMIT_OBJECT_NAME
 779|/ /  Author: A U Thor <author@example.com>
 780| |
 781| |       fourth
 782| |   ---
 783| |    ein | 1 +
 784| |    1 file changed, 1 insertion(+)
 785| |
 786| |   diff --git a/ein b/ein
 787| |   new file mode 100644
 788| |   index 0000000..9d7e69f
 789| |   --- /dev/null
 790| |   +++ b/ein
 791| |   @@ -0,0 +1 @@
 792| |   +ichi
 793| |
 794* | commit COMMIT_OBJECT_NAME
 795|/  Author: A U Thor <author@example.com>
 796|
 797|       third
 798|   ---
 799|    ichi | 1 +
 800|    one  | 1 -
 801|    2 files changed, 1 insertion(+), 1 deletion(-)
 802|
 803|   diff --git a/ichi b/ichi
 804|   new file mode 100644
 805|   index 0000000..9d7e69f
 806|   --- /dev/null
 807|   +++ b/ichi
 808|   @@ -0,0 +1 @@
 809|   +ichi
 810|   diff --git a/one b/one
 811|   deleted file mode 100644
 812|   index 9d7e69f..0000000
 813|   --- a/one
 814|   +++ /dev/null
 815|   @@ -1 +0,0 @@
 816|   -ichi
 817|
 818* commit COMMIT_OBJECT_NAME
 819| Author: A U Thor <author@example.com>
 820|
 821|     second
 822| ---
 823|  one | 2 +-
 824|  1 file changed, 1 insertion(+), 1 deletion(-)
 825|
 826| diff --git a/one b/one
 827| index 5626abf..9d7e69f 100644
 828| --- a/one
 829| +++ b/one
 830| @@ -1 +1 @@
 831| -one
 832| +ichi
 833|
 834* commit COMMIT_OBJECT_NAME
 835  Author: A U Thor <author@example.com>
 836
 837      initial
 838  ---
 839   one | 1 +
 840   1 file changed, 1 insertion(+)
 841
 842  diff --git a/one b/one
 843  new file mode 100644
 844  index 0000000..5626abf
 845  --- /dev/null
 846  +++ b/one
 847  @@ -0,0 +1 @@
 848  +one
 849EOF
 850
 851sanitize_output () {
 852        sed -e 's/ *$//' \
 853            -e 's/commit [0-9a-f]*$/commit COMMIT_OBJECT_NAME/' \
 854            -e 's/Merge: [ 0-9a-f]*$/Merge: MERGE_PARENTS/' \
 855            -e 's/Merge tag.*/Merge HEADS DESCRIPTION/' \
 856            -e 's/Merge commit.*/Merge HEADS DESCRIPTION/' \
 857            -e 's/, 0 deletions(-)//' \
 858            -e 's/, 0 insertions(+)//' \
 859            -e 's/ 1 files changed, / 1 file changed, /' \
 860            -e 's/, 1 deletions(-)/, 1 deletion(-)/' \
 861            -e 's/, 1 insertions(+)/, 1 insertion(+)/'
 862}
 863
 864test_expect_success 'log --graph with diff and stats' '
 865        git log --no-renames --graph --pretty=short --stat -p >actual &&
 866        sanitize_output >actual.sanitized <actual &&
 867        test_i18ncmp expect actual.sanitized
 868'
 869
 870test_expect_success 'dotdot is a parent directory' '
 871        mkdir -p a/b &&
 872        ( echo sixth && echo fifth ) >expect &&
 873        ( cd a/b && git log --format=%s .. ) >actual &&
 874        test_cmp expect actual
 875'
 876
 877test_expect_success GPG 'setup signed branch' '
 878        test_when_finished "git reset --hard && git checkout master" &&
 879        git checkout -b signed master &&
 880        echo foo >foo &&
 881        git add foo &&
 882        git commit -S -m signed_commit
 883'
 884
 885test_expect_success GPG 'log --graph --show-signature' '
 886        git log --graph --show-signature -n1 signed >actual &&
 887        grep "^| gpg: Signature made" actual &&
 888        grep "^| gpg: Good signature" actual
 889'
 890
 891test_expect_success GPG 'log --graph --show-signature for merged tag' '
 892        test_when_finished "git reset --hard && git checkout master" &&
 893        git checkout -b plain master &&
 894        echo aaa >bar &&
 895        git add bar &&
 896        git commit -m bar_commit &&
 897        git checkout -b tagged master &&
 898        echo bbb >baz &&
 899        git add baz &&
 900        git commit -m baz_commit &&
 901        git tag -s -m signed_tag_msg signed_tag &&
 902        git checkout plain &&
 903        git merge --no-ff -m msg signed_tag &&
 904        git log --graph --show-signature -n1 plain >actual &&
 905        grep "^|\\\  merged tag" actual &&
 906        grep "^| | gpg: Signature made" actual &&
 907        grep "^| | gpg: Good signature" actual
 908'
 909
 910test_expect_success GPG '--no-show-signature overrides --show-signature' '
 911        git log -1 --show-signature --no-show-signature signed >actual &&
 912        ! grep "^gpg:" actual
 913'
 914
 915test_expect_success GPG 'log.showsignature=true behaves like --show-signature' '
 916        test_config log.showsignature true &&
 917        git log -1 signed >actual &&
 918        grep "gpg: Signature made" actual &&
 919        grep "gpg: Good signature" actual
 920'
 921
 922test_expect_success GPG '--no-show-signature overrides log.showsignature=true' '
 923        test_config log.showsignature true &&
 924        git log -1 --no-show-signature signed >actual &&
 925        ! grep "^gpg:" actual
 926'
 927
 928test_expect_success GPG '--show-signature overrides log.showsignature=false' '
 929        test_config log.showsignature false &&
 930        git log -1 --show-signature signed >actual &&
 931        grep "gpg: Signature made" actual &&
 932        grep "gpg: Good signature" actual
 933'
 934
 935test_expect_success 'log --graph --no-walk is forbidden' '
 936        test_must_fail git log --graph --no-walk
 937'
 938
 939test_expect_success 'log diagnoses bogus HEAD' '
 940        git init empty &&
 941        test_must_fail git -C empty log 2>stderr &&
 942        test_i18ngrep does.not.have.any.commits stderr &&
 943        echo 1234abcd >empty/.git/refs/heads/master &&
 944        test_must_fail git -C empty log 2>stderr &&
 945        test_i18ngrep broken stderr &&
 946        echo "ref: refs/heads/invalid.lock" >empty/.git/HEAD &&
 947        test_must_fail git -C empty log 2>stderr &&
 948        test_i18ngrep broken stderr &&
 949        test_must_fail git -C empty log --default totally-bogus 2>stderr &&
 950        test_i18ngrep broken stderr
 951'
 952
 953test_expect_success 'set up --source tests' '
 954        git checkout --orphan source-a &&
 955        test_commit one &&
 956        test_commit two &&
 957        git checkout -b source-b HEAD^ &&
 958        test_commit three
 959'
 960
 961test_expect_success 'log --source paints branch names' '
 962        cat >expect <<-\EOF &&
 963        09e12a9 source-b three
 964        8e393e1 source-a two
 965        1ac6c77 source-b one
 966        EOF
 967        git log --oneline --source source-a source-b >actual &&
 968        test_cmp expect actual
 969'
 970
 971test_expect_success 'log --source paints tag names' '
 972        git tag -m tagged source-tag &&
 973        cat >expect <<-\EOF &&
 974        09e12a9 source-tag three
 975        8e393e1 source-a two
 976        1ac6c77 source-tag one
 977        EOF
 978        git log --oneline --source source-tag source-a >actual &&
 979        test_cmp expect actual
 980'
 981
 982test_done