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

Re: [PATCH/RFC] sequencer.c: record revert/cherry-pick commit with trailer lines

From
PWPhillip Wood <phillip.wood@talktalk.net>
Date
Nov 4, 2018, 21:12 UTC
Message-ID
<1a667e9c-3944-4bc3-fb60-68e79dff0c34@talktalk.net>
In-Reply-To
<CACsJy8CAw6yR5vbsFJbSd+UTR_1UpS=8PP3hEtbSNSi3SkMNag@mail.gmail.com>
Hi Duy
On 04/11/2018 17:41, Duy Nguyen wrote:
Show 50 quoted lines
> On Sun, Nov 4, 2018 at 5:45 PM Phillip Wood <phillip.wood@talktalk.net> wrote:
>>
>> On 04/11/2018 07:22, Nguyễn Thái Ngọc Duy wrote:
>>> When a commit is reverted (or cherry-picked with -x) we add an English
>>> sentence recording that commit id in the new commit message. Make
>>> these real trailer lines instead so that they are more friendly to
>>> parsers (especially "git interpret-trailers").
>>>
>>> A reverted commit will have a new trailer
>>>
>>>       Revert: <commit-id>
>>>
>>> Similarly a cherry-picked commit with -x will have
>>>
>>>       Cherry-Pick: <commit-id>
>>
>> I think this is a good idea though I wonder if it will break someones
>> script that is looking for the messages generated by -x at the moment.
> 
> It will [1] but I still think it's worth the trouble. The script will
> be less likely to break after, and you can use git-interpret-trailers
> instead of plain grep.
> 
> [1] https://public-inbox.org/git/20181017143921.GR270328@devbig004.ftw2.facebook.com/
> 
>>> @@ -1758,16 +1757,10 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
>>>                base_label = msg.label;
>>>                next = parent;
>>>                next_label = msg.parent_label;
>>> -             strbuf_addstr(&msgbuf, "Revert \"");
>>> -             strbuf_addstr(&msgbuf, msg.subject);
>>> -             strbuf_addstr(&msgbuf, "\"\n\nThis reverts commit ");
>>> -             strbuf_addstr(&msgbuf, oid_to_hex(&commit->object.oid));
>>> -
>>> -             if (commit->parents && commit->parents->next) {
>>> -                     strbuf_addstr(&msgbuf, ", reversing\nchanges made to ");
>>> -                     strbuf_addstr(&msgbuf, oid_to_hex(&parent->object.oid));
>>> -             }
>>
>> As revert currently records the parent given on the command line when
>> reverting a merge commit it would probably be a good idea to add that
>> either as a separate trailer or to the Revert: trailer and possibly also
>> generate it for cherry picks.
> 
> My mistake. I didn't read carefully and thought it was logging
> commit->parents, which is pointless.
> 
> So what should be the trailer for this (I don't think putting it in
> Revert: is a good idea, too much to parse)? Revert-parent: ?
> Revert-merge: ?

I think Revert-parent: is good, though you seem to have gone for including it the Revert: trailer in v2.

Show 8 quoted lines
>>> -             strbuf_addstr(&msgbuf, ".\n");
>>> +             strbuf_addf(&msgbuf, "Revert \"%s\"\n\n", msg.subject);
>>
>> If the message already contains trailers then should we just append the
>> Revert trailer those rather than inserting "\n\n"?
> 
> Umm.. but this \n\n is for separating the subject and the body. I
> think we need it anyway, trailer or not.

Ah you're right, I had forgotten that the revert message body is empty, unlike cherry-pick where the message is copied (and that does the right thing already when there are existing trailers).

Best wishes
Phillip
Show 12 quoted lines
>>> @@ -1784,9 +1777,8 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
>>>                        strbuf_complete_line(&msgbuf);
>>>                        if (!has_conforming_footer(&msgbuf, NULL, 0))
>>>                                strbuf_addch(&msgbuf, '\n');
>>> -                     strbuf_addstr(&msgbuf, cherry_picked_prefix);
>>> -                     strbuf_addstr(&msgbuf, oid_to_hex(&commit->object.oid));
>>> -                     strbuf_addstr(&msgbuf, ")\n");
>>> +                     strbuf_addf(&msgbuf, "Cherry-Pick: %s\n",
>>> +                                 oid_to_hex(&commit->object.oid));
> 
> I will probably make this "Cherry-picked-from:" to match our S-o-b style.
> 
Previous: Duy NguyenNext: Johannes Schindelin
Message 4 of 25 in “sequencer.c: record revert/cherry-pick commit with trailer lines”
  1. sequencer.c: record revert/cherry-pick commit with trailer linesNguyễn Thái Ngọc Duy, Nov 4, 2018
  2. Phillip WoodNov 4, 2018
  3. Duy NguyenNov 4, 2018
  4. Phillip WoodNov 4, 2018
  5. Johannes SchindelinNov 5, 2018
  6. sequencer.c: record revert/cherry-pick commit with trailer linesNguyễn Thái Ngọc Duy, Nov 4, 2018
  7. brian m. carlsonNov 4, 2018
  8. Duy NguyenNov 5, 2018
  9. Support --append-trailer in cherry-pick and revertNguyễn Thái Ngọc Duy, Nov 6, 2018
  10. Ævar Arnfjörð BjarmasonNov 6, 2018
  11. Jeff KingNov 6, 2018
  12. Jeff KingNov 6, 2018
  13. Junio C HamanoNov 7, 2018
  14. Duy NguyenNov 7, 2018
  15. Jeff KingNov 7, 2018
  16. Junio C HamanoNov 8, 2018
  17. Jeff KingNov 8, 2018
  18. Junio C HamanoNov 8, 2018
  19. Junio C HamanoNov 7, 2018
  20. Junio C HamanoNov 5, 2018
  21. Duy NguyenNov 5, 2018
  22. Junio C HamanoNov 6, 2018
  23. Ævar Arnfjörð BjarmasonNov 6, 2018
  24. Duy NguyenNov 6, 2018
  25. Ævar Arnfjörð BjarmasonNov 6, 2018

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.