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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:45:48

From: Robin Rosenberg <redacted>
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 <redacted>
Signed-off-by: Junio C Hamano <redacted>
---
  "Boyd Stephen Smith Jr." [off-list ref] 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;

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

From: Robin Rosenberg <hidden>
Date: 2016-06-15 22:45:48

söndag 21 december 2008 23:17:12 skrev Junio C Hamano:
From: Robin Rosenberg <redacted>
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.]
No need for this comment.
+			add_to_msg(",\nreverting damages made to %s");
maybe "changes" is more neutrral language. I also think you break
the line too early.

Are we done now?

-- robin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help