From: Jeff King <peff@peff.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
git@vger.kernel.org, phillip.wood@dunelm.org.uk,
andals@crustytoothpaste.net, "Junio C Hamano" <gitster@pobox.com>,
Johannes.Schindelin@gmx.de
Subject: Re: [PATCH/RFC] Support --append-trailer in cherry-pick and revert
Date: Tue, 6 Nov 2018 17:29:12 -0500 [thread overview]
Message-ID: <20181106222912.GA14820@sigill.intra.peff.net> (raw)
In-Reply-To: <20181106221118.GA9975@sigill.intra.peff.net>
On Tue, Nov 06, 2018 at 05:11:18PM -0500, Jeff King wrote:
> On Tue, Nov 06, 2018 at 06:48:22PM +0100, Ævar Arnfjörð Bjarmason wrote:
>
> > The implementation looks fine to me, but as noted in
> > https://public-inbox.org/git/8736se6qyc.fsf@evledraar.gmail.com/ I
> > wonder what the plausible end-game is. That we'll turn this on by
> > default in a few years, and then you can only worry about
> > git-interpret-trailers for repos created as of 2020 or something?
> >
> > Otherwise it seems we'll need to *also* parse out the existing messages
> > we've added.
>
> Could we help the reading scripts by normalizing old and new output via
> interpret-trailers, %(trailers), etc?
>
> I think "(cherry picked from ...)" is already considered a trailer by
> the trailer code. If the caller instructs us to, we could probably
> rewrite it to:
>
> Cherry-picked-from: ...
>
> in the output. Then the end-game is that scripts should just use
> interpret-trailers, etc, and old and new commits will Just Work.
I.e., something like this:
diff --git a/trailer.c b/trailer.c
index 0796f326b3..491c7c240e 100644
--- a/trailer.c
+++ b/trailer.c
@@ -46,9 +46,11 @@ static int configured;
#define TRAILER_ARG_STRING "$ARG"
+#define CHERRY_PICK_PREFIX "(cherry picked from commit "
+
static const char *git_generated_prefixes[] = {
"Signed-off-by: ",
- "(cherry picked from commit ",
+ CHERRY_PICK_PREFIX,
NULL
};
@@ -1141,6 +1143,8 @@ static void format_trailer_info(struct strbuf *out,
for (i = 0; i < info->trailer_nr; i++) {
char *trailer = info->trailers[i];
ssize_t separator_pos = find_separator(trailer, separators);
+ const char *hex;
+ struct object_id oid;
if (separator_pos >= 1) {
struct strbuf tok = STRBUF_INIT;
@@ -1154,6 +1158,12 @@ static void format_trailer_info(struct strbuf *out,
strbuf_release(&tok);
strbuf_release(&val);
+ } else if (/* should check opts->normalize_cherry_pick */1 &&
+ skip_prefix(trailer, CHERRY_PICK_PREFIX, &hex) &&
+ !get_oid_hex(hex, &oid)) {
+ strbuf_addf(out, "Cherry-picked-from: %s\n",
+ oid_to_hex(&oid));
+
} else if (!opts->only_trailers) {
strbuf_addstr(out, trailer);
}
That would need to add the normalize_cherry_pick flag to the options
struct, and then plumb it through. But it's enough to play around with,
and:
git log --format='%h%n%(trailers:only)'
works.
-Peff
next prev parent reply other threads:[~2018-11-06 22:29 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 [this message]
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
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=20181106222912.GA14820@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=andals@crustytoothpaste.net \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--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).