git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH 0/4] interpret-trailers: introduce "move" action

From
Christian Couder <christian.couder@gmail.com>
Date
Oct 6, 2017, 10:30 UTC
Message-ID
<CAP8UFD1X-aRN5sAB5PQt04jL_92APK279bjNf=Zt_x8KOxyL+A@mail.gmail.com>
In-Reply-To
<20171005132243.27058-1-pbonzini@redhat.com>
On Thu, Oct 5, 2017 at 3:22 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
Show 32 quoted lines
> 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...
Did you try using `--where end --if-exists replace --trailer "$sob"`?
Previous: Paolo BonziniNext: Paolo Bonzini
Message 8 of 14 in “interpret-trailers: introduce "move" action”
  1. 0/4 interpret-trailers: introduce "move" actionPaolo Bonzini, Oct 5, 2017
  2. 3/4 trailer: create a new function to handle adding trailersPaolo Bonzini, Oct 5, 2017
  3. 4/4 trailer: add "move" configuration for trailer.ifExistsPaolo Bonzini, Oct 5, 2017
  4. 1/4 trailer: push free_arg_item upPaolo Bonzini, Oct 5, 2017
  5. 2/4 trailer: simplify check_if_differentPaolo Bonzini, Oct 5, 2017
  6. Junio C HamanoOct 6, 2017
  7. Paolo BonziniOct 6, 2017
  8. Christian CouderOct 6, 2017
  9. Paolo BonziniOct 6, 2017
  10. Christian CouderOct 6, 2017
  11. Paolo BonziniOct 6, 2017
  12. Christian CouderOct 6, 2017
  13. Paolo BonziniOct 6, 2017
  14. Junio C HamanoOct 7, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.