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

Re: [PATCH] Make git revert warn the user when reverting a merge commit.

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 21, 2008, 22:17 UTC
Message-ID
<7vprjlkwbb.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<200812211513.26808.bss@iguanasuicide.net>
From: Robin Rosenberg <robin.rosenberg.lists@dewire.com>
Subject: git-revert: record the parent against which a revert was made

As described in Documentation/howto/revert-a-faulty-merge.txt, re-merging from a previously reverted a merge of a side branch may need a revert of the revert beforehand. Record against which parent the revert was made in the commit, so that later the user can figure out what went on.

[jc: original had the logic in the message reversed, so I tweaked it.]
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
  "Boyd Stephen Smith Jr." <bss@iguanasuicide.net> writes:
  > I still think the parent we are reverting to should be mentioned in the 
  > automatically generated commit message, even if it is the first parent.  Even 
  > if it is decided to elide that information for the first parent, I agree 
  > that, at least for now, the "-m" should still be required when reverting a 
  > merge commit.
  Ok, so here is Robin's patch with a bit of rewording.  I want to have
  something usable now, so that I can tag -rc4 and still have time left
  for sipping my Caipirinha in the evening ;-)
  I think we later _could_ use this information inside ancestry traversal
  made while computing the merge base in such a way to eliminate the
  necessity of the "revert of the revert".  When we see a message that
  records a revert of a merge, we keep a mental note of it, and when we
  encounter such a merge during the ancestry traversal, we pretend as if
  the merge never happened (i.e. instead we traverse only the named
  parent).
  But that needs more thought, and we do not have to do that now.
 builtin-revert.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git c/builtin-revert.c w/builtin-revert.c
index 4038b41..fae0fe8 100644
--- c/builtin-revert.c
+++ w/builtin-revert.c
@@ -352,6 +352,11 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 		add_to_msg(oneline_body + 1);
 		add_to_msg("\"\n\nThis reverts commit ");
 		add_to_msg(sha1_to_hex(commit->object.sha1));
+
+		if (commit->parents->next) {
+			add_to_msg(",\nreverting damages made to %s");
+			add_to_msg(sha1_to_hex(parent->object.sha1));
+		}
 		add_to_msg(".\n");
 	} else {
 		base = parent;
Previous: Boyd Stephen Smith Jr.Next: Junio C Hamano
Message 20 of 24 in “Make git revert warn the user when reverting a merge commit.”
  1. Make git revert warn the user when reverting a merge commit.Boyd Stephen Smith Jr., Dec 19, 2008
  2. Johannes SchindelinDec 19, 2008
  3. Junio C HamanoDec 19, 2008
  4. Boyd Stephen Smith Jr.Dec 19, 2008
  5. Jay SoffianDec 19, 2008
  6. Boyd Stephen Smith Jr.Dec 19, 2008
  7. Junio C HamanoDec 19, 2008
  8. AlanDec 19, 2008
  9. Boyd Stephen Smith Jr.Dec 19, 2008
  10. Robin RosenbergDec 20, 2008
  11. Boyd Stephen Smith Jr.Dec 20, 2008
  12. Robin RosenbergDec 20, 2008
  13. Junio C HamanoDec 21, 2008
  14. Boyd Stephen Smith Jr.Dec 21, 2008
  15. Robin RosenbergDec 21, 2008
  16. Junio C HamanoDec 21, 2008
  17. Boyd Stephen Smith Jr.Dec 21, 2008
  18. Junio C HamanoDec 21, 2008
  19. Boyd Stephen Smith Jr.Dec 21, 2008
  20. Junio C HamanoDec 21, 2008
  21. Junio C HamanoDec 21, 2008
  22. Robin RosenbergDec 21, 2008
  23. Junio C HamanoDec 21, 2008
  24. Robin RosenbergDec 21, 2008

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.