From: Miklos Vajna <vmiklos@suse.cz>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH] merge: allow using --no-ff and --ff-only at the same time
Date: Mon, 1 Jul 2013 09:01:43 +0200 [thread overview]
Message-ID: <20130701070143.GB17269@suse.cz> (raw)
1347483 (Teach 'git merge' and 'git pull' the option --ff-only,
2009-10-29) says this is not allowed, as they contradict each other.
However, --ff-only is about asserting the input of the merge, and
--no-ff is about instructing merge to always create a merge commit, i.e.
it makes sense to use these options together in some workflow, e.g. when
branches are integrated by rebasing then merging, and the maintainer
wants to be sure the branch is rebased.
Signed-off-by: Miklos Vajna <vmiklos@suse.cz>
---
builtin/merge.c | 12 ++++++++----
t/t7600-merge.sh | 11 ++++++++---
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/builtin/merge.c b/builtin/merge.c
index 2ebe732..7026ce0 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1162,9 +1162,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
option_commit = 0;
}
- if (!allow_fast_forward && fast_forward_only)
- die(_("You cannot combine --no-ff with --ff-only."));
-
if (!abort_current_merge) {
if (!argc) {
if (default_to_upstream)
@@ -1433,7 +1430,14 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
}
}
- if (fast_forward_only)
+ /*
+ * If --ff-only was used without --no-ff, or: --ff-only and --no-ff was
+ * used at the same time, and this is not a fast-forward.
+ */
+ if (fast_forward_only && (allow_fast_forward || remoteheads->next ||
+ common->next ||
+ hashcmp(common->item->object.sha1,
+ head_commit->object.sha1)))
die(_("Not possible to fast-forward, aborting."));
/* We are going to make a new commit. */
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 460d8eb..bf3d9b2 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -497,9 +497,14 @@ test_expect_success 'combining --squash and --no-ff is refused' '
test_must_fail git merge --no-ff --squash c1
'
-test_expect_success 'combining --ff-only and --no-ff is refused' '
- test_must_fail git merge --ff-only --no-ff c1 &&
- test_must_fail git merge --no-ff --ff-only c1
+test_expect_success 'combining --ff-only and --no-ff (ff is possible)' '
+ git reset --hard c0 &&
+ git merge --ff-only --no-ff c1
+'
+
+test_expect_success 'combining --ff-only and --no-ff (ff is not possible)' '
+ git reset --hard c1 &&
+ test_must_fail git merge --ff-only --no-ff c2
'
test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '
--
1.8.1.4
next reply other threads:[~2013-07-01 7:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-01 7:01 Miklos Vajna [this message]
2013-07-01 14:52 ` [PATCH] merge: allow using --no-ff and --ff-only at the same time Michael Haggerty
2013-07-01 15:27 ` Miklos Vajna
2013-07-01 15:38 ` Junio C Hamano
2013-07-01 16:10 ` Miklos Vajna
2013-07-01 16:43 ` Junio C Hamano
2013-07-01 19:54 ` [PATCH] merge: handle --ff/--no-ff/--ff-only as a tri-state option Miklos Vajna
2013-07-01 20:27 ` Junio C Hamano
2013-07-02 8:42 ` Michael Haggerty
2013-07-02 14:47 ` [PATCH v2] " Miklos Vajna
2013-07-02 20:12 ` Junio C Hamano
2013-07-02 18:46 ` [PATCH] " Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130701070143.GB17269@suse.cz \
--to=vmiklos@suse.cz \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).