git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug Report: Multi-line trailers containing empty lines break parsing

From
ZheNing Hu <adlternative@gmail.com>
Date
Mar 26, 2021, 10:25 UTC
Message-ID
<CAOLTT8QPJJWh_Xm=n+i7z5+5w=eBq9tcr5-yBmhovzqOXP=jnQ@mail.gmail.com>
In-Reply-To
<xmqqmturw13r.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> 于2021年3月26日周五 上午2:16写道:
Show 33 quoted lines
>
> ZheNing Hu <adlternative@gmail.com> writes:
>
> > Christian Couder <christian.couder@gmail.com> 于2021年3月25日周四 下午3:54写道:
> >>
> >> Maybe it's not enough, but the doc already has the following:
> >>
> >> ------
> >> Existing trailers are extracted from the input message by looking for
> >> a group of one or more lines that (i) is all trailers, or (ii) contains at
> >> least one Git-generated or user-configured trailer and consists of at
> >> least 25% trailers.
> >> The group must be preceded by one or more empty (or whitespace-only) lines.
> >> The group must either be at the end of the message or be the last
> >> non-whitespace lines before a line that starts with '---' (followed by a
> >> space or the end of the line). Such three minus signs start the patch
> >> part of the message. See also `--no-divider` below.
> >>
> >> When reading trailers, there can be whitespaces after the
> >> token, the separator and the value. There can also be whitespaces
> >> inside the token and the value. The value may be split over multiple lines with
> >> each subsequent line starting with whitespace, like the "folding" in RFC 822.
> >> ------
> >
> >
> > Maybe I don't have enough right to speak on this issue, but I always think that
> >  the empty line is intentional by the designer, especially when I test it.
>
> People like you, who is relatively new to the system and the list,
> are valuable source of information for us to learn where in the
> current system and documentation we have room to improve and
> clarify.  You do have right, and we welcome your input.
>
Thanks:)
Show 6 quoted lines
> Care to clarify what you mean by "the empty line is intentional by
> the designer"?  The designer of the current "trailer" intended to
> make the "last paragraph" (where "paragraph" is defined as a run of
> lines without an empty line in it, so that one or more continguous
> empty lines separate "paragraphs") where the trailers sit in the log
> message.  Is that what you mean?  Or something else?

Emmm, I mean generally speaking, the entire commit infomations is divided into three paragraphs: "subject"/"message"/"trailers".

When we use `--parse` to get those trailers, normally it can indeed be obtained, But if in the middle of the trailers have a extra empty lines or lines with only whitespaces, All trailers before the blank line will be discarded, I think it is acceptable.Because It seems that the previous content belongs to the message section.

Like this: ------ (subject)

First paragraph: hello world

Second paragraph: what happen if some thing like

this: Use git to commit code to git
Signed-off-by: CoCo <cc@gg.com>
Deleted-by: ADL <a@gg.com>
-----

"this: Use git to commit code to git" seem like a trailer, but it's user's message.

So I think the purpose of these blank lines is to separate the three parts of the commit information. It is normal for the blank lines inside trailers to cause ambiguity.

Please correct me if I what I said is wrong. -- ZheNing Hu

Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 12 in “Bug Report: Multi-line trailers containing empty lines break parsing”
  1. Matthias BuehlmannFeb 15, 2021
  2. Junio C HamanoFeb 16, 2021
  3. Taylor BlauFeb 16, 2021
  4. Junio C HamanoFeb 16, 2021
  5. Taylor BlauFeb 16, 2021
  6. Christian CouderMar 23, 2021
  7. Junio C HamanoMar 23, 2021
  8. Christian CouderMar 25, 2021
  9. ZheNing HuMar 25, 2021
  10. Junio C HamanoMar 25, 2021
  11. ZheNing HuMar 26, 2021
  12. Junio C HamanoMar 25, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.