git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Sixt <j6t@kdbg.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Paul Tan <pyokagan@gmail.com>,
	Git Mailing List <git@vger.kernel.org>, Jeff King <peff@peff.net>
Subject: Re: More builtin git-am issues..
Date: Mon, 7 Sep 2015 21:27:09 +0200	[thread overview]
Message-ID: <CAP8UFD1AoSsP303NEMLf39o-RHEwRMt-GvUv-87kCGtpA56Piw@mail.gmail.com> (raw)
In-Reply-To: <xmqqsi6sbqqm.fsf@gitster.mtv.corp.google.com>

On Sat, Sep 5, 2015 at 9:39 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> To salvage "interpret-trailers" needs a lot more, as we are
>> realizing that the definition that led to its external design does
>> not match the way users use footers in the real world.  This affects
>> the internal data representation and the whole thing needs to be
>> rethought.
>
> Note that I am not saying that you personally did any bad job while
> working on the interpret-trailers topic.  We collectively designed
> its feature based on a much narrower definition of what the trailer
> block is than what is used in the real world in practice, so we do
> not have a good way to locate an existing entry that is not a (key,
> value), no matter what the syntax to denote which is key and which
> is value is, insert a new entry that is not a (key, value), or
> remove an existing entry that is not a (key, value), all of which
> will be necessary to mutate trailer blocks people use in the real
> life.
>
> I think a good way forward would be to go like this:
>
>  * a helper function that starts from a flat <buf, len> (or a
>    strbuf) and identifies the end of the body of the message,
>    i.e. find "^---$", "^Conflicts:$", etc. and skip blank lines
>    backwards.  That is what ignore_non_trailer() in commit.c does,
>    and that can be shared across everybody that mutates a log
>    message.
>
>  * a helper function that takes the result of the above as a flat
>    <buf, len> (or a strbuf) and identifies the beginning of a
>    trailer block.  That may be just the matter of scanning backwards
>    from the end of the trailer block ignore_non_trailer() identified
>    for the first blank line, as I agree with Linus's "So quite
>    frankly, at that point if git doesn't recognize it as a sign-off
>    block, I don't think it's a big deal" in the thread.
>
>    Not having that and not calling that function can reintroduce the
>    recent "interpret-trailers corner case" bug Matthieu brought up.
>
> With these, everybody except interpret-trailers that mutates a log
> message can add a new signoff consistently.  And then, building on
> these, "interpret-trailers" can be written like this:
>
>  (1) starting from a flat <buf, len> (or a strbuf), using the above
>      helpers, identify the parts of the log message that is the
>      trailer block (and you will know what is before and what is
>      after the trailer block).
>
>  (2) keep the part before the trailer block and the part after the
>      trailer block (this could be empty) in one strbuf each; we do
>      not want to mutate these parts, and it is pointless to split
>      them further into individual lines.
>
>  (3) express the lines in the trailer block in a richer data
>      structure that is easier to manipulate (i.e. reorder the lines,
>      insert, delete, etc.) and work on it.
>
>  (4) when manipulation of the trailer block is finished, reconstruct
>      the resulting message by concatenating the "before trailer"
>      part, "trailer" part, and "after trailer" part.
>
> As to the exact design of "a richer data structure" and the
> manipulation we may want on the trailer, I currently do not have a
> strong "it should be this way" opinion yet, but after looking at
> various examples Linus gave us in the discussion, my gut feelig is
> that it would be best to keep the operation simple and generic,
> e.g. "find a line that matches this regexp and replace it with this
> line", "insert this line at the end", "delete all lines that match
> this regexp", etc.

I will see what I can do about this.

Thanks,
Christian.

  reply	other threads:[~2015-09-07 19:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04 23:47 More builtin git-am issues Linus Torvalds
2015-09-04 23:52 ` Linus Torvalds
2015-09-05  0:07   ` Jeff King
2015-09-05  0:36     ` Linus Torvalds
2015-09-05  0:54   ` Junio C Hamano
2015-09-05  1:06     ` Linus Torvalds
2015-09-05  1:23       ` Junio C Hamano
2015-09-05  1:35         ` Linus Torvalds
2015-09-05 16:01           ` Junio C Hamano
2015-09-05  7:30     ` Johannes Sixt
2015-09-05  8:03       ` Jeff King
2015-09-05 16:10         ` Junio C Hamano
2015-09-05 16:32           ` Junio C Hamano
2015-09-05 16:57             ` Junio C Hamano
2015-09-05 19:39           ` Junio C Hamano
2015-09-07 19:27             ` Christian Couder [this message]
2015-09-05 15:24       ` Junio C Hamano
2015-09-05 15:34         ` Junio C Hamano
2015-09-05  1:06 ` Junio C Hamano
2015-09-05  1:20   ` Linus Torvalds
2015-09-05  1:24     ` Junio C Hamano
2015-09-06  4:56 ` [PATCH] am: match --signoff to the original scripted version Junio C Hamano
2015-09-06  9:04   ` Paul Tan
2015-09-06 17:24     ` Junio C Hamano
2015-09-08  6:18       ` Jeff King
2015-09-06 14:21   ` Paul Tan
2015-09-06 17:39     ` Junio C Hamano
2015-09-06 16:16   ` Linus Torvalds
2015-09-08  6:25   ` Jeff King
2015-09-08 18:14     ` 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

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

  git send-email \
    --in-reply-to=CAP8UFD1AoSsP303NEMLf39o-RHEwRMt-GvUv-87kCGtpA56Piw@mail.gmail.com \
    --to=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=peff@peff.net \
    --cc=pyokagan@gmail.com \
    --cc=torvalds@linux-foundation.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.
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 NNTP newsgroup(s).