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

Re: [RFC] cover-at-tip

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 13, 2017, 10:30 UTC
Message-ID
<xmqqbmk68o9d.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqh8ty8q5x.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
> Nicolas Morey-Chaisemartin <NMoreyChaisemartin@suse.de> writes:
>
>> I agree this is a "am" job. Was just wondering if reusing some of
>> the code from apply (and move it so it makes more sense) wouldnd't
>> make more sense than rewriting a patch detection function.
>
> Yes, I understood that and have already given an answer, no?
This was a bit too terse to be useful, so let me try again.

I think the ideal endgame would be to allow people to come up with a topic branch of this shape (illustrated is a three-patch series on top of 'origin'):

    ---o---o (origin)
            \
             1---2---3

and then add an empty commit C whose log message is used to store "cover letter material", i.e.

    ---o---o (origin)
            \
             1---2---3---C (topic)
And then you should be able to 
 (1) merge such branch yourself, coming up with a history like this,
     where merge M uses material from C in the merge log message
    ---o---o---x---x---M
            \         /
             1---2---3
 (2) "git format-patch origin..topic" that would create the cover
     letter using material found in C in addition to the usual
     stuff (like shortlog) generated by "format-patch --cover",
     followed by these three patches.
 (3) "git format-patch M" should be able to (a) realize that M
     merges a side branch that is a three-commit series (i.e.
     M^1..M^2), and (b) notice that log message of M has
     human-readable description.  Then it grabs the merge log
     message of M and do the same as (2).
 (4) "git am" the result from (2) or (3) should recreate the
     original history i.e. what we started with with C.
    ---o---o (origin)
            \
             1---2---3---C (topic)

Now, I _think_ what the machinery needs a lot more is to be able to detect C is an empty commit (when doing (2)), and then you have quite a lattitude in designing what exactly such an automated cover letter looks like, so that the receiving end (4) can recognize it more easily and (more importantly) more robustly than "the message does not have any patch in it". Not all random messages that do not have a patch in it are cover letters, and that is why I do not think touching any code in the apply layer in an attempt to "reuse" anything is a bad idea. It will risk butchering the code without any real gain, because what we really need to know is *not* absence of patch, but presence of cover letter material.

The simplest would probably be to notice that the subject of one has 0/N on it, while other messages were labeled with 1/N..(N-1)/N; that would be a lot stronger clue that 0/N has a cover than "it does not have any patch in it".

It may be that we would not just want to identify which message is cover and which message is not, but which part of the cover letter message should go back to the log message of the capping empty commit (and moved to the merge log message). Just like we invented the conventions like scissors, three-dashes, etc., you might want to come up with a way to do so in your format-patch enhancement used to do the (2) and (3) above. Then it will be the matter of teaching that convention to "am" used in (4).

Previous: Junio C HamanoNext: Nicolas Morey-Chaisemartin
Message 6 of 25 in “[RFC] cover-at-tip”
  1. Nicolas Morey-ChaisemartinNov 10, 2017
  2. Nicolas Morey-ChaisemartinNov 10, 2017
  3. Junio C HamanoNov 10, 2017
  4. Nicolas Morey-ChaisemartinNov 13, 2017
  5. Junio C HamanoNov 13, 2017
  6. Junio C HamanoNov 13, 2017
  7. Nicolas Morey-ChaisemartinNov 13, 2017
  8. 0/3 Add support for --cover-at-tipNicolas Morey-Chaisemartin, Nov 13, 2017
  9. Jonathan TanNov 13, 2017
  10. Nicolas Morey-ChaisemartinNov 13, 2017
  11. 1/3 mailinfo: extract patch series idNicolas Morey-Chaisemartin, Nov 13, 2017
  12. Junio C HamanoNov 14, 2017
  13. Nicolas Morey-ChaisemartinNov 14, 2017
  14. 2/3 am: semi working --cover-at-tipNicolas Morey-Chaisemartin, Nov 13, 2017
  15. Junio C HamanoNov 14, 2017
  16. Nicolas Morey-ChaisemartinNov 14, 2017
  17. Nicolas Morey-ChaisemartinNov 16, 2017
  18. Junio C HamanoNov 17, 2017
  19. 3/3 log: add an option to generate cover letter from a branch tipNicolas Morey-Chaisemartin, Nov 13, 2017
  20. Junio C HamanoNov 14, 2017
  21. Nicolas Morey-ChaisemartinNov 14, 2017
  22. Junio C HamanoNov 14, 2017
  23. Nicolas Morey-ChaisemartinNov 14, 2017
  24. Junio C HamanoNov 14, 2017
  25. Jonathan TanNov 10, 2017

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.