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

Re: [RFC/PATCH 0/2] place cherry pick line below commit title

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 30, 2016, 20:49 UTC
Message-ID
<xmqqtwcx8669.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqq8tu99o75.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 22 quoted lines
> Jonathan Tan <jonathantanmy@google.com> writes:
>
>>> I vaguely recall that there were some discussion on the definition
>>> of "what's a trailer line" with folks from the kernel land, perhaps
>>> while discussing the interpret-trailers topic.  IIRC, when somebody
>>> passes an improved version along, the resulting message's trailer
>>> block may look like this:
>>>
>>>     Signed-off-by: Original Author <original@author.xz>
>>>     [fixed typo in the variable names]
>>>     Signed-off-by: Somebhody Else <somebody@else.xz>
>>>
>>> and an obvious "wish" of theirs was to treat not just RFC2822-like
>>> "a line that begins with token followed by a colon" but also these
>>> short comments as part of the trailer block.  Your original wish in
>>> [*1*] is to also treat "a line that begin with a whitespace that
>>> follows a line that begins with token followed by a colon" as part
>>> of the trailer block and I personally think that is a reasonable
>>> thing to wish for, too.
>>
>> If we allowed arbitrary lines in the trailer block, this would solve
>> my original problem, yes.

Here is an experiment I ran during my lunch break. The script (attached) is meant to run in the kernel repository and for each log messages of each non-merge commit:

 * find its last paragraph, where the definition of paragraph is
   simply "a blank/empty line";
 * inspect if there is at least one RFC2822-header-looking line, or
   a line that begins with "(cherry picked from";
 * dump the ones that do not pass the above criteria.

My cursory look of the output did not spot a legitimate trailer block that we should have identified. The output lines shown were ones that are not signed off at all (e.g. af8c34ce6ae32add that says "Linux 4.7-rc2"), ones that has three-dash line "---" in them (e.g. 133d558216d9), ones that has diffstat that should have been after "---" (e.g. 259307074bfcf1f).

The story is the same if you run it in git.git; the "do we have at least one rfc2822-header-looking line or '(cherry picked from' line in the last paragraph? if so, then that is an existing trailer block" seems to be a good heuristics to cover many cases like these:

    d0196c8d5d3057c5c21a82f3d0113ca8e501033b
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    [tomi.valkeinen@ti.com: resolved conflicts]
    Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
    59f0aa9480cfef9173a648cec4537addc5f3ad94
    Link 1: https://bugzilla.kernel.org/show_bug.cgi?id=9916
            http://bugzilla.kernel.org/show_bug.cgi?id=10100
            https://lkml.org/lkml/2008/2/25/282
    Link 2: https://bugzilla.kernel.org/show_bug.cgi?id=9399
            https://bugzilla.kernel.org/show_bug.cgi?id=12461
            https://bugzilla.kernel.org/show_bug.cgi?id=11880
    Link 3: https://bugzilla.kernel.org/show_bug.cgi?id=11884
            https://bugzilla.kernel.org/show_bug.cgi?id=14081
            https://bugzilla.kernel.org/show_bug.cgi?id=14086
            https://bugzilla.kernel.org/show_bug.cgi?id=14446
    Link 4: https://bugzilla.kernel.org/show_bug.cgi?id=112911
    Signed-off-by: Lv Zheng <lv.zheng@intel.com>
    Tested-by: Chris Bainbridge <chris.bainbridge@gmail.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

-- >8 -- #!/bin/sh

git log --no-merges |
perl -e '
	sub flush {
		my ($commit, @lines) = @_;
		my $seen_good = 0;
		for (@lines) {
			if (/^[-A-Za-z0-9]+: / ||
			    /^\(cherry picked from/) {
				$seen_good = 1;
				last;
			}
		}
		if (!$seen_good) {
			print "\n$commit\n";
			for (@lines) {
				print;
			}
		}
	}
	my (@lines, $this);
	while (<>) {
		if (/^commit (.*)$/) {
			my $next = $1;
			flush($this, @lines);
			@lines = ();
			$this = $next;
		}
		if (s/^    //) {
			if (/^\s*$/) {
				@lines = ();
			} else {
				push @lines, $_;
			}
		}
	}
	if (@lines && $this) {
		flush($this, @lines);
	}
'
Previous: Junio C HamanoNext: Jonathan Tan
Message 9 of 20 in “place cherry pick line below commit title”
  1. 0/2 place cherry pick line below commit titleJonathan Tan, Sep 29, 2016
  2. 2/2 sequencer: allow origin line below commit titleJonathan Tan, Sep 29, 2016
  3. 1/2 sequencer: refactor message and origin appendingJonathan Tan, Sep 29, 2016
  4. Junio C HamanoSep 29, 2016
  5. Jonathan TanSep 30, 2016
  6. Junio C HamanoSep 30, 2016
  7. Jonathan TanSep 30, 2016
  8. Junio C HamanoOct 3, 2016
  9. Junio C HamanoSep 30, 2016
  10. Jonathan TanOct 3, 2016
  11. Junio C HamanoOct 3, 2016
  12. Jonathan TanOct 3, 2016
  13. Junio C HamanoOct 3, 2016
  14. Jonathan TanOct 4, 2016
  15. Junio C HamanoOct 4, 2016
  16. Junio C HamanoOct 4, 2016
  17. Jonathan TanOct 5, 2016
  18. Junio C HamanoOct 6, 2016
  19. Jonathan TanOct 5, 2016
  20. Junio C HamanoOct 5, 2016

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.