On Mon, Oct 28, 2024, at 19:43, Nicholas Sielicki wrote: > If one uses `git cherry-pick -x' to apply a commit to a stable branch > from elsewhere, git appends something like: > >> Tested-by: Some Teammate <some.teammate@xxxxxxxxxxxxxx> >> Signed-off-by: Some User <some.user@xxxxxxxxxxxxxx> >> (cherry picked from commit 2efe13923d0ff714b1b0f3b7175e714f0e295727) <--- this > > IMO this is inconsistent in two ways: > > 1. it's unclear to me why the cherry-pick metadata isn't emitted in > trailer form, ie: `Cherry-Picked-From-Commit: <...>', making it work > with `git-interpret-trailers'. I agree that would be better. Modulo history and backwards compatibility concerns. > 2. I'm not sure if any tooling (external or otherwise) breaks because > of this, but the existing trailers now have non-trailer content > following them, so it's ambiguous whether they still qualify as > trailers at first glance. (possibly, this is intentional?) They still qualify. See git-interpret-trailers(1) “ Existing trailers are extracted from the input by looking for a group of one or more lines that (i) is all trailers, or (ii) contains at least one Git-generated or user-configured trailer and consists of at least 25% trailers. That example would work even if you only had one existing trailer (50% at the end). I don’t know what the significance of “user-configured” is here. I deleted all my configuration and tested with something made up and `git interpret-trailers --parse`. Those novel-looking trailers still got output as trailers when placed before a cherry-pick line. > Realistically, the only thing worse than this^ would be to have a > mixture of two formats in the same repository, which is to say, > without a surefire way to to share repository config defaults, I can't > imagine there's a backwards-compatible solution to changing the `-x' > default behavior and git is stuck with it. Make a new option? Like `--trailer`? > It could be possible to extend the existing behavior with git-notes? > Added benefit of that would be that you could mark both commits > involved with `Cherry-Picked-By' and `Cherry-Picked-From'. Why Notes? A trailer (a proper one) seems more straightforward. There was a “crossreference” patch series from 2018: https://lore.kernel.org/git/20181211234909.2855638-1-tj@xxxxxxxxxx/ ❦ You could emulate something like `git cherry-pick --trailer`: ``` #!/bin/sh # arg 1: commit set -u $ git config trailer.cherry.key Cherry-picked-from $ cat script #!/bin/sh git showref "$1" $ git config trailer.cherry.cmd ./script $ git cherry-pick "$1" && $ git commit --trailer="cherry: $1" \ --amend --no-edit ```