[PATCH] Make git revert warn the user when reverting a merge commit.
From: Boyd Stephen Smith Jr. <hidden>
Date: 2016-06-15 22:45:48
Subsystem:
the rest · Maintainer:
Linus Torvalds
Signed-off-by: Boyd Stephen Smith Jr <redacted> --- 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/ \_/