git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] interpret-trailers: introduce "move" action
@ 2017-10-05 13:22 Paolo Bonzini
  2017-10-05 13:22 ` [PATCH 1/4] trailer: push free_arg_item up Paolo Bonzini
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Paolo Bonzini @ 2017-10-05 13:22 UTC (permalink / raw)
  To: git

The purpose of this action is for scripts to be able to keep the
user's Signed-off-by at the end.  For example say I have a script
that adds a Reviewed-by tag:

    #! /bin/sh
    them=$(git log -i -1 --pretty='format:%an <%ae>' --author="$*")
    trailer="Reviewed-by: $them"
    git log -1 --pretty=format:%B | \
      git interpret-trailers --where end --if-exists doNothing --trailer "$trailer" | \
      git commit --amend -F-

Now, this script will leave my Signed-off-by line in a non-canonical
place, like

   Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
   Reviewed-by: Junio C Hamano <gitster@pobox.com>

This new option enables the following improvement:

    #! /bin/sh
    me=$(git var GIT_COMMITTER_IDENT | sed 's,>.*,>,')
    them=$(git log -i -1 --pretty='format:%an <%ae>' --author="$*")
    trailer="Reviewed-by: $them"
    sob="Signed-off-by: $me"
    git log -1 --pretty=format:%B | \
      git interpret-trailers --where end --if-exists doNothing --trailer "$trailer" \
                             --where end --if-exists move --if-missing doNothing --trailer "$sob" | \
      git commit --amend -F-

which lets me keep the SoB line at the end, as it should be.
Posting as RFC because it's possible that I'm missing a simpler
way to achieve this...

Paolo Bonzini (4):
  trailer: push free_arg_item up
  trailer: simplify check_if_different
  trailer: create a new function to handle adding trailers
  trailer: add "move" configuration for trailer.ifExists

 Documentation/git-interpret-trailers.txt |  13 ++-
 t/t7513-interpret-trailers.sh            |  37 +++++++
 trailer.c                                | 169 ++++++++++++++++++-------------
 trailer.h                                |   1 +
 4 files changed, 149 insertions(+), 71 deletions(-)

-- 
2.14.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-10-07  0:51 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-05 13:22 [RFC PATCH 0/4] interpret-trailers: introduce "move" action Paolo Bonzini
2017-10-05 13:22 ` [PATCH 1/4] trailer: push free_arg_item up Paolo Bonzini
2017-10-05 13:22 ` [PATCH 2/4] trailer: simplify check_if_different Paolo Bonzini
2017-10-05 13:22 ` [PATCH 3/4] trailer: create a new function to handle adding trailers Paolo Bonzini
2017-10-05 13:22 ` [PATCH 4/4] trailer: add "move" configuration for trailer.ifExists Paolo Bonzini
2017-10-06  6:44 ` [RFC PATCH 0/4] interpret-trailers: introduce "move" action Junio C Hamano
2017-10-06  7:26   ` Paolo Bonzini
2017-10-06 10:30 ` Christian Couder
2017-10-06 10:40   ` Paolo Bonzini
2017-10-06 12:33     ` Christian Couder
2017-10-06 12:39       ` Paolo Bonzini
2017-10-06 13:19         ` Christian Couder
2017-10-06 13:49           ` Paolo Bonzini
2017-10-07  0:51         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).