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

Re: [PATCH v3 1/2] sequencer: beautify subject of reverts of reverts

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Aug 11, 2023, 15:05 UTC
Message-ID
<dba3f15a-3575-e4f9-2291-c5a342cfed43@gmail.com>
In-Reply-To
<20230809171531.2564807-1-oswald.buddenhagen@gmx.de>
Hi Oswald
On 09/08/2023 18:15, Oswald Buddenhagen wrote:
Show 12 quoted lines
> Instead of generating a silly-looking `Revert "Revert "foo""`, make it
> a more humane `Reapply "foo"`.
> 
> This is done for two reasons:
> - To cover the actually common case of just a double revert.
> - To encourage people to rewrite summaries of recursive reverts by
>    setting an example (a subsequent commit will also do this explicitly
>    in the documentation).
> 
> To achieve these goals, the mechanism does not need to be particularly
> sophisticated. Therefore, more complicated alternatives which would
> "compress more efficiently" have not been implemented.

This all looks good to me, it seems quite sensible just to bail out if we see an existing recursive reversion. I'm not suggesting you change these tests but for future reference we now have a test_commit_message() function which was merged a few days ago to simplify tests like these.

Thanks for working on it
Phillip
Show 90 quoted lines
> Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
> 
> ---
> v3:
> - capitulate at first sight of a pre-existing recursive reversion, as
>    handling the edge cases is a bottomless pit
> - reworked commit message again
> - moved test into existing file
> - generalized docu change and factored it out
> 
> v2:
> - add discussion to commit message
> - add paragraph to docu
> - add test
> - use skip_prefix() instead of starts_with()
> - catch pre-existing double reverts
> 
> Cc: Junio C Hamano <gitster@pobox.com>
> Cc: Kristoffer Haugsbakk <code@khaugsbakk.name>
> Cc: Phillip Wood <phillip.wood123@gmail.com>
> ---
>   sequencer.c                   | 11 +++++++++++
>   t/t3501-revert-cherry-pick.sh | 25 +++++++++++++++++++++++++
>   2 files changed, 36 insertions(+)
> 
> diff --git a/sequencer.c b/sequencer.c
> index cc9821ece2..12ec158922 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -2249,13 +2249,24 @@ static int do_pick_commit(struct repository *r,
>   	 */
>   
>   	if (command == TODO_REVERT) {
> +		const char *orig_subject;
> +
>   		base = commit;
>   		base_label = msg.label;
>   		next = parent;
>   		next_label = msg.parent_label;
>   		if (opts->commit_use_reference) {
>   			strbuf_addstr(&msgbuf,
>   				"# *** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***");
> +		} else if (skip_prefix(msg.subject, "Revert \"", &orig_subject) &&
> +			   /*
> +			    * We don't touch pre-existing repeated reverts, because
> +			    * theoretically these can be nested arbitrarily deeply,
> +			    * thus requiring excessive complexity to deal with.
> +			    */
> +			   !starts_with(orig_subject, "Revert \"")) {
> +			strbuf_addstr(&msgbuf, "Reapply \"");
> +			strbuf_addstr(&msgbuf, orig_subject);
>   		} else {
>   			strbuf_addstr(&msgbuf, "Revert \"");
>   			strbuf_addstr(&msgbuf, msg.subject);
> diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
> index e2ef619323..7011e3a421 100755
> --- a/t/t3501-revert-cherry-pick.sh
> +++ b/t/t3501-revert-cherry-pick.sh
> @@ -176,6 +176,31 @@ test_expect_success 'advice from failed revert' '
>   	test_cmp expected actual
>   '
>   
> +test_expect_success 'title of fresh reverts' '
> +	test_commit --no-tag A file1 &&
> +	test_commit --no-tag B file1 &&
> +	git revert --no-edit HEAD &&
> +	echo "Revert \"B\"" >expect &&
> +	git log -1 --pretty=%s >actual &&
> +	test_cmp expect actual &&
> +	git revert --no-edit HEAD &&
> +	echo "Reapply \"B\"" >expect &&
> +	git log -1 --pretty=%s >actual &&
> +	test_cmp expect actual &&
> +	git revert --no-edit HEAD &&
> +	echo "Revert \"Reapply \"B\"\"" >expect &&
> +	git log -1 --pretty=%s >actual &&
> +	test_cmp expect actual
> +'
> +
> +test_expect_success 'title of legacy double revert' '
> +	test_commit --no-tag "Revert \"Revert \"B\"\"" file1 &&
> +	git revert --no-edit HEAD &&
> +	echo "Revert \"Revert \"Revert \"B\"\"\"" >expect &&
> +	git log -1 --pretty=%s >actual &&
> +	test_cmp expect actual
> +'
> +
>   test_expect_success 'identification of reverted commit (default)' '
>   	test_commit to-ident &&
>   	test_when_finished "git reset --hard to-ident" &&
Previous: Junio C HamanoNext: Junio C Hamano
Message 42 of 53 in “sequencer: beautify subject of reverts of reverts”
  1. sequencer: beautify subject of reverts of revertsOswald Buddenhagen, Apr 28, 2023
  2. Junio C HamanoApr 28, 2023
  3. Oswald BuddenhagenApr 28, 2023
  4. Junio C HamanoMay 1, 2023
  5. Oswald BuddenhagenMay 1, 2023
  6. Junio C HamanoMay 1, 2023
  7. Junio C HamanoMay 5, 2023
  8. Phillip WoodMay 17, 2023
  9. Oswald BuddenhagenMay 17, 2023
  10. Phillip WoodMay 17, 2023
  11. Oswald BuddenhagenMay 17, 2023
  12. Phillip WoodMay 18, 2023
  13. Junio C HamanoMay 18, 2023
  14. Linus ArverJul 28, 2023
  15. Oswald BuddenhagenJul 28, 2023
  16. Junio C HamanoJul 28, 2023
  17. Oswald BuddenhagenJul 28, 2023
  18. Junio C HamanoJul 28, 2023
  19. Oswald BuddenhagenJul 28, 2023
  20. Linus ArverJul 28, 2023
  21. 1/2 sequencer: beautify subject of reverts of revertsOswald Buddenhagen, Aug 9, 2023
  22. 2/2 doc: revert: add discussionOswald Buddenhagen, Aug 9, 2023
  23. Linus ArverAug 10, 2023
  24. Linus ArverAug 10, 2023
  25. Oswald BuddenhagenAug 11, 2023
  26. Linus ArverAug 11, 2023
  27. Oswald BuddenhagenAug 12, 2023
  28. Linus ArverSep 7, 2023
  29. Phillip WoodAug 11, 2023
  30. Oswald BuddenhagenAug 12, 2023
  31. Junio C HamanoAug 13, 2023
  32. Oswald BuddenhagenAug 14, 2023
  33. Phillip WoodAug 11, 2023
  34. Junio C HamanoAug 11, 2023
  35. Junio C HamanoAug 11, 2023
  36. Re* [PATCH v3 2/2] doc: revert: add discussionJunio C Hamano, Aug 11, 2023
  37. Junio C HamanoAug 11, 2023
  38. rsbecker@nexbridge.comAug 11, 2023
  39. Eric SunshineAug 11, 2023
  40. Oswald BuddenhagenAug 11, 2023
  41. Junio C HamanoAug 11, 2023
  42. Phillip WoodAug 11, 2023
  43. Junio C HamanoAug 11, 2023
  44. Oswald BuddenhagenAug 11, 2023
  45. 1/2 sequencer: beautify subject of reverts of revertsOswald Buddenhagen, Aug 21, 2023
  46. 2/2 git-revert.txt: add discussionOswald Buddenhagen, Aug 21, 2023
  47. Junio C HamanoAug 21, 2023
  48. Taylor BlauAug 23, 2023
  49. Junio C HamanoAug 23, 2023
  50. Oswald BuddenhagenAug 24, 2023
  51. sequencer: beautify subject of reverts of revertsOswald Buddenhagen, Sep 2, 2023
  52. Junio C HamanoSep 2, 2023
  53. Kristoffer HaugsbakkSep 11, 2023

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.