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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Boyd Stephen Smith Jr <bss@xxxxxxxxxxxxxxxxx>
---
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@xxxxxxxxxxxxxxxxx                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux