git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: git <git@vger.kernel.org>
Subject: Re: [RFC PATCH 0/4] interpret-trailers: introduce "move" action
Date: Fri, 6 Oct 2017 12:40:36 +0200	[thread overview]
Message-ID: <748131b7-bddd-08c2-ff72-9fd1a63ef6a0@redhat.com> (raw)
In-Reply-To: <CAP8UFD1X-aRN5sAB5PQt04jL_92APK279bjNf=Zt_x8KOxyL+A@mail.gmail.com>

On 06/10/2017 12:30, Christian Couder wrote:
> On Thu, Oct 5, 2017 at 3:22 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> 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"`?

Yes, it's a different behavior; "--if-exists replace" matches on others'
SoB as well, so it would eat the original author's SoB if I didn't have one.

So "move" does get it wrong for

    Signed-off-by: Me
    Signed-off-by: Friend

(Me gets moved last, which may not be what you want) but "replace" gets
it wrong in the arguably more common case of

    Signed-off-by: Friend

which is damaged to just "Signed-off-by: Me".

Paolo

  reply	other threads:[~2017-10-06 10:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=748131b7-bddd-08c2-ff72-9fd1a63ef6a0@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).