git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Make git revert warn the user when reverting a merge commit.
@ 2008-12-19  2:39 Boyd Stephen Smith Jr.
  2008-12-19  2:57 ` Johannes Schindelin
  2008-12-20  7:08 ` Robin Rosenberg
  0 siblings, 2 replies; 24+ messages in thread
From: Boyd Stephen Smith Jr. @ 2008-12-19  2:39 UTC (permalink / raw)
  To: git

Signed-off-by: Boyd Stephen Smith Jr <bss@iguanasuicide.net>
---
On Thursday 2008 December 18 18:21:25 Linus Torvalds wrote:
> I suspect we should warn about reverting merges.

Here is a patch (aginst c0ceb2c, which I believe is master currently) that
does just that.

After applying the patch I get the following test results:
fixed   1
success 4108
failed  0
broken  4
total   4113

 builtin-revert.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/builtin-revert.c b/builtin-revert.c
index 4038b41..7f121a5 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -296,6 +296,21 @@ static int revert_or_cherry_pick(int argc, const char 
**argv)
 		int cnt;
 		struct commit_list *p;
 
+		do {
+			switch (action) {
+			case REVERT:
+				warning("revert on a merge commit may not do what you expect.");
+				continue;
+			case CHERRY_PICK:
+				/* Cherry picking a merge doesn't merge the history, but
+				 * I don't think many people expect that.
+				 */
+				continue;
+			}
+			/* Unhandled enum member. */
+			die("Unknown action on a merge commit.");
+		} while (0);
+
 		if (!mainline)
 			die("Commit %s is a merge but no -m option was given.",
 			    sha1_to_hex(commit->object.sha1));
-- 
1.5.6
-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     

^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2008-12-21 22:58 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-19  2:39 [PATCH] Make git revert warn the user when reverting a merge commit Boyd Stephen Smith Jr.
2008-12-19  2:57 ` Johannes Schindelin
2008-12-19  3:03   ` Junio C Hamano
2008-12-19  3:29     ` Boyd Stephen Smith Jr.
2008-12-19  3:55       ` Jay Soffian
2008-12-19  5:54         ` Boyd Stephen Smith Jr.
2008-12-19  6:35           ` Junio C Hamano
2008-12-19 18:07       ` Alan
2008-12-19  3:24   ` Boyd Stephen Smith Jr.
2008-12-20  7:08 ` Robin Rosenberg
2008-12-20 22:54   ` Boyd Stephen Smith Jr.
2008-12-20 23:31     ` Robin Rosenberg
2008-12-21  2:37       ` Junio C Hamano
2008-12-21  3:11         ` Boyd Stephen Smith Jr.
2008-12-21 10:09           ` Robin Rosenberg
2008-12-21 10:59             ` Junio C Hamano
2008-12-21 19:59             ` Boyd Stephen Smith Jr.
2008-12-21 20:23               ` Junio C Hamano
2008-12-21 21:13                 ` Boyd Stephen Smith Jr.
2008-12-21 22:17                   ` Junio C Hamano
2008-12-21 22:38                     ` Junio C Hamano
2008-12-21 22:40                     ` Robin Rosenberg
2008-12-21 22:46                       ` Junio C Hamano
2008-12-21 22:56                         ` Robin Rosenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).