threads / patch / 29663

patchcherry-pick -x: always insert an empty line

Subject: [PATCH] cherry-pick -x: always insert an empty line

## tl;dr

5 messages between Feb 18, 2012 and Feb 23, 2012. Diffs are folded; open one to read it.

replies: 4people: 3as markdown or json

Beat Bolli· Feb 18, 2012, 21:14 UTC · lore

When cherry-picking a commit that has only a summary, the -x option creates an invalid commit message because it puts the hash of the commit being picked on the second line which should be left empty.

This patch fixes this buglet by always inserting an empty line before the added line.

Aside from that, even with a non-trivial commit the generated note "(cherry picked from commit 555c9864971744abb558796aea28e12a1ac20839)" seems abrupt when appended directly.

Cc: Eric Raible <raible@nextest.com>
Signed-off-by: Beat Bolli <bbolli@ewanet.ch>
---
 sequencer.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to sequencer.c +1 −1
diff --git a/sequencer.c b/sequencer.c
index 5fcbcb8..63fd589 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -382,7 +382,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
 		}
 
 		if (opts->record_origin) {
-			strbuf_addstr(&msgbuf, "(cherry picked from commit ");
+			strbuf_addstr(&msgbuf, "\n(cherry picked from commit ");
 			strbuf_addstr(&msgbuf, sha1_to_hex(commit->object.sha1));
 			strbuf_addstr(&msgbuf, ")\n");
 		}
-- 
1.7.9
Junio C Hamano· Feb 19, 2012, 08:44 UTC · re: Beat Bolli · lore

Re: [PATCH] cherry-pick -x: always insert an empty line

Beat Bolli <bbolli@ewanet.ch> writes:
Show 27 quoted lines
> When cherry-picking a commit that has only a summary, the -x option
> creates an invalid commit message because it puts the hash of the commit
> being picked on the second line which should be left empty.
>
> This patch fixes this buglet by always inserting an empty line before
> the added line.
>
> Aside from that, even with a non-trivial commit the generated note
> "(cherry picked from commit 555c9864971744abb558796aea28e12a1ac20839)"
> seems abrupt when appended directly.
>
> Cc: Eric Raible <raible@nextest.com>
> Signed-off-by: Beat Bolli <bbolli@ewanet.ch>
> ---
>  sequencer.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index 5fcbcb8..63fd589 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -382,7 +382,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
>  		}
>  
>  		if (opts->record_origin) {
> -			strbuf_addstr(&msgbuf, "(cherry picked from commit ");
> +			strbuf_addstr(&msgbuf, "\n(cherry picked from commit ");
Doesn't this need to be conditional?

If we cherry pick your commit somewhere else with "-x -s", the resulting commit log message would end like this:

    Aside from that, even with a non-trivial commit the generated note
    "(cherry picked from commit 555c9864971744abb558796aea28e12a1ac20839)"
    seems abrupt when appended directly.
    Cc: Eric Raible <raible@nextest.com>
    Signed-off-by: Beat Bolli <bbolli@ewanet.ch>
    (cherry picked from commit 555c9864971744abb558796aea28e12a1ac20839)
    Signed-off-by: Frotz Xyzzy <nitfol@example.xz>
which clearly is worse-looking with the extra LF you added in this patch.
>  			strbuf_addstr(&msgbuf, sha1_to_hex(commit->object.sha1));
>  			strbuf_addstr(&msgbuf, ")\n");
>  		}
Beat Bolli· Feb 23, 2012, 08:39 UTC · re: Junio C Hamano · lore

Re: [PATCH] cherry-pick -x: always insert an empty line

On 2012-02-19 09:44, Junio C Hamano wrote:
Show 46 quoted lines
> Beat Bolli <bbolli@ewanet.ch> writes:
> 
>> When cherry-picking a commit that has only a summary, the -x option
>> creates an invalid commit message because it puts the hash of the commit
>> being picked on the second line which should be left empty.
>>
>> This patch fixes this buglet by always inserting an empty line before
>> the added line.
>>
>> Aside from that, even with a non-trivial commit the generated note
>> "(cherry picked from commit 555c9864971744abb558796aea28e12a1ac20839)"
>> seems abrupt when appended directly.
>>
>> Cc: Eric Raible <raible@nextest.com>
>> Signed-off-by: Beat Bolli <bbolli@ewanet.ch>
>> ---
>>  sequencer.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/sequencer.c b/sequencer.c
>> index 5fcbcb8..63fd589 100644
>> --- a/sequencer.c
>> +++ b/sequencer.c
>> @@ -382,7 +382,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
>>  		}
>>  
>>  		if (opts->record_origin) {
>> -			strbuf_addstr(&msgbuf, "(cherry picked from commit ");
>> +			strbuf_addstr(&msgbuf, "\n(cherry picked from commit ");
> 
> Doesn't this need to be conditional?
> 
> If we cherry pick your commit somewhere else with "-x -s", the resulting
> commit log message would end like this:
> 
>     Aside from that, even with a non-trivial commit the generated note
>     "(cherry picked from commit 555c9864971744abb558796aea28e12a1ac20839)"
>     seems abrupt when appended directly.
> 
>     Cc: Eric Raible <raible@nextest.com>
>     Signed-off-by: Beat Bolli <bbolli@ewanet.ch>
> 
>     (cherry picked from commit 555c9864971744abb558796aea28e12a1ac20839)
>     Signed-off-by: Frotz Xyzzy <nitfol@example.xz>
> 
> which clearly is worse-looking with the extra LF you added in this patch.

What should the condition then be? What is the canonical format for cherry-picks with Signed-off-by: and Cc: footer lines?

> 
>>  			strbuf_addstr(&msgbuf, sha1_to_hex(commit->object.sha1));
>>  			strbuf_addstr(&msgbuf, ")\n");
>>  		}
-- 
mail: echo '<bNbolOli@ewaSPnetAM.ch>' | tr -d '[A-S]'
pgp: 0x506A903A; 49D5 794A EA77 F907 764F  D89E 304B 93CF 506A 903A
gsm: 4.7.7.6.0.7.7.9.7.1.4.e164.arpa
icbm: 47.0452 N, 7.2715 E
http: www.drbeat.li

"It takes love over gold, and mind over matter" -- Dire Straits
Sebastian Schuberth· Feb 23, 2012, 09:38 UTC · re: Junio C Hamano · lore

Re: [PATCH] cherry-pick -x: always insert an empty line

On 19.02.2012 09:44, Junio C Hamano wrote:
Show 14 quoted lines
> If we cherry pick your commit somewhere else with "-x -s", the resulting
> commit log message would end like this:
>
>      Aside from that, even with a non-trivial commit the generated note
>      "(cherry picked from commit 555c9864971744abb558796aea28e12a1ac20839)"
>      seems abrupt when appended directly.
>
>      Cc: Eric Raible<raible@nextest.com>
>      Signed-off-by: Beat Bolli<bbolli@ewanet.ch>
>
>      (cherry picked from commit 555c9864971744abb558796aea28e12a1ac20839)
>      Signed-off-by: Frotz Xyzzy<nitfol@example.xz>
>
> which clearly is worse-looking with the extra LF you added in this patch.

Clearly? I would not say so, on the contrary. When using -s together with -x, I'd interpret this as signing off the process of cherry-picking itself, and as such, visually grouping the additional "signed-off" with the "cherry picked from" makes sense to me.

-- 
Sebastian Schuberth
Sebastian Schuberth· Feb 23, 2012, 08:56 UTC · re: Beat Bolli · lore

Re: [PATCH] cherry-pick -x: always insert an empty line

On 18.02.2012 22:14, Beat Bolli wrote:
> This patch fixes this buglet by always inserting an empty line before
> the added line.

Thanks for this! Not having an empty line there has annoyed me, too, several times.

-- 
Sebastian Schuberth

← back to recent threads