RE: Possible bug regarding trailers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Eric,

"eric.frederich@xxxxxxxxxxx" <eric.frederich@xxxxxxxxxxx> writes:

B)
Should anything that is retrieved via:
     `git cat-file commit $SHA | git interpret-trailers --parse`
also be displayed via:
`git log -1 --format="%(trailers:key=some-key,valueonly,separator=%x2c) %H %T" $SHA`

... why is there a difference? (Explicit call to interpret-trailers shows the trailer, but the log command does not).

For reference (using your repro script), I get:

    $ git cat-file commit HEAD~ | sed -e '1,/^$/d'
    A bad commit

    old-scm-change-id: THIS TRAILER GETS LOST

    --- let's mess stuff up ---

    Have fun
    $ git cat-file commit HEAD~ | git interpret-trailers --parse
    old-scm-change-id: THIS TRAILER GETS LOST
$ git cat-file commit HEAD~ | git interpret-trailers --parse --no-divider $ git log -1 --format="%(trailers:key=some-key,valueonly,separator=%x2c) %H %T" HEAD~ a1d5cfede3cbd109a353235a495e66f86e7456e4 1dd017bdd070190005e5e162d87afebcd61e0fa8

I agree with Peff that interpret-trailers and git-log are both behaving
correctly. For

    $ git cat-file commit HEAD~ | git interpret-trailers --parse
    old-scm-change-id: THIS TRAILER GETS LOST

we detect the trailer because interpret-trailers treats the "--- let's
mess stuff up ---" line as a git-format-patch-like divider separating
the commit message from the patch diff. This is working as intended.

Contrast this with the invocation where we pass in "--no-divider" and
interpret-trailers (correctly) treats the "---" as _not_ a divider and
so considers the "old-scm-change-id: THIS TRAILER GETS LOST" line as
part of the commit message's body text. As there are no trailers at the
bottom, it parses no trailers and nothing is printed on the output. This
is working as intended.

For
$ git log -1 --format="%(trailers:key=some-key,valueonly,separator=%x2c) %H %T" HEAD~ a1d5cfede3cbd109a353235a495e66f86e7456e4 1dd017bdd070190005e5e162d87afebcd61e0fa8

the git-log command already knows that it is dealing with input that is
only the commit message. And so it behaves the same way as
interpret-trailers with the "--no-divider" flag (treating the entire
input as a commit message). This is working as intended.

The issue (as Peff pointed out) is the insertion of the trailer by
git-commit before the "--- let's mess stuff up ---" line. Instead we
should make git-commit insert the

    old-scm-change-id: THIS TRAILER GETS LOST

line _after_ the "Have fun" line. If so, then the calls to
interpret-trailers and git-log should behave more intuitively.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux