git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, phillip.wood@dunelm.org.uk,
	andals@crustytoothpaste.net, "Ævar Arnfjörð" <avarab@gmail.com>,
	Johannes.Schindelin@gmx.de
Subject: Re: [PATCH/RFC] Support --append-trailer in cherry-pick and revert
Date: Wed, 07 Nov 2018 09:31:07 +0900	[thread overview]
Message-ID: <xmqq4lctenjo.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20181106171637.15562-1-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Tue, 6 Nov 2018 18:16:37 +0100")

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> OK here is a less constroversal attempt to add new trailers. Instead
> of changing the default behavior (which could be done incrementally
> later), this patch simply adds a new option --append-trailer to revert
> and cherry-pick.

I almost agree, except that the the textual description in a revert
and the funny-looking trailer-wannabe in a cherry-pick are two
fundamentally different things, and adding duplicate to the latter
does not make much sense, while keeping both does make sense for the
former.

> PS. maybe --append-trailer is too generic? We have --signoff which is
> also a trailer. But that one carries more weights than just "machine
> generated tags".

> +		if (opts->append_trailer) {
> +			strbuf_addstr(&msgbuf, "\n");
> +			if (parent_id != -1)
> +				strbuf_addf(&msgbuf, "Reverts: %s~%d\n",
> +					    oid_to_hex(&commit->object.oid),
> +					    parent_id);
> +			else
> +				strbuf_addf(&msgbuf, "Reverts: %s\n",
> +					    oid_to_hex(&commit->object.oid));
> +		}

Makes sense, I guess.

> @@ -1780,14 +1792,28 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
>  		if (find_commit_subject(msg.message, &p))
>  			strbuf_addstr(&msgbuf, p);
>  
> -		if (opts->record_origin) {
> +		if (opts->record_origin || opts->append_trailer) {
>  			strbuf_complete_line(&msgbuf);
>  			if (!has_conforming_footer(&msgbuf, NULL, 0))
>  				strbuf_addch(&msgbuf, '\n');
> +		}
> +
> +		if (opts->record_origin) {
>  			strbuf_addstr(&msgbuf, cherry_picked_prefix);
>  			strbuf_addstr(&msgbuf, oid_to_hex(&commit->object.oid));
>  			strbuf_addstr(&msgbuf, ")\n");
>  		}
> +		if (opts->append_trailer) {

These should be either-or, I would think, as adding exactly the same
piece of information in two different machine-readable form does not
make much sense.  The command line parser may even want to make sure
that both are not given at the same time.

Alternatively, we can keep using -x as "we are going to record where
the change was cherry-picked from" and use .record_origin to store
that bit, and use the new .append_trailer bit as "if we are recording
the origin, in which format between the old and the new do we do
so?" bit.

I think the latter makes more sense, at least to me.


> +			if (opts->record_origin)
> +				strbuf_addstr(&msgbuf, "\n");
> +			if (parent_id != -1)
> +				strbuf_addf(&msgbuf, "Cherry-picked-from: %s~%d\n",
> +					    oid_to_hex(&commit->object.oid),
> +					    parent_id);
> +			else
> +				strbuf_addf(&msgbuf, "Cherry-picked-from: %s\n",
> +					    oid_to_hex(&commit->object.oid));
> +		}

  parent reply	other threads:[~2018-11-07  0:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-04  7:22 [PATCH/RFC] sequencer.c: record revert/cherry-pick commit with trailer lines Nguyễn Thái Ngọc Duy
2018-11-04 16:45 ` Phillip Wood
2018-11-04 17:41   ` Duy Nguyen
2018-11-04 21:12     ` Phillip Wood
2018-11-05 21:57     ` Johannes Schindelin
2018-11-04 18:10 ` [PATCH/RFC v2] " Nguyễn Thái Ngọc Duy
2018-11-04 21:30   ` brian m. carlson
2018-11-05 16:08     ` Duy Nguyen
2018-11-06 17:16   ` [PATCH/RFC] Support --append-trailer in cherry-pick and revert Nguyễn Thái Ngọc Duy
2018-11-06 17:48     ` Ævar Arnfjörð Bjarmason
2018-11-06 22:11       ` Jeff King
2018-11-06 22:29         ` Jeff King
2018-11-07  0:42         ` Junio C Hamano
2018-11-07 15:30         ` Duy Nguyen
2018-11-07 21:02           ` Jeff King
2018-11-08  0:36           ` Junio C Hamano
2018-11-08  1:29             ` Jeff King
2018-11-08  3:34               ` Junio C Hamano
2018-11-07  0:31     ` Junio C Hamano [this message]
2018-11-05  0:56 ` [PATCH/RFC] sequencer.c: record revert/cherry-pick commit with trailer lines Junio C Hamano
2018-11-05 16:17   ` Duy Nguyen
2018-11-06  1:44     ` Junio C Hamano
2018-11-06  8:57 ` Ævar Arnfjörð Bjarmason
2018-11-06 16:13   ` Duy Nguyen
2018-11-06 17:44     ` Ævar Arnfjörð Bjarmason

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=xmqq4lctenjo.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=andals@crustytoothpaste.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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).