summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-04-26 14:09:21 -0700
committerJunio C Hamano <gitster@pobox.com>2016-04-26 14:34:51 -0700
commitae599b1c18f689c39ccc87657d47a6ead9c61cb0 (patch)
treeda36c441099867709625925357d003fb7078d2b9
parent625efa9decb64e2b51c4bef342922553729cf2f6 (diff)
downloadgit-ae599b1c18f689c39ccc87657d47a6ead9c61cb0.tar.gz
merge: do not contaminate option_commit with --squash
It is true that we do not make a commit when we are asked to do "merge --squash", and the code does so by setting option_commit variable to zero when seeing the squash option. But this made it impossible to see from the value of option_commit if --no-commit was given from the command line, or --squash turned it off. We check for the value of option_commit at only two places. Check for the value of squash at them, too. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/merge.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index bf2f2614fb..f641751e4b 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1237,11 +1237,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
if (verbosity < 0)
show_diffstat = 0;
- if (squash) {
- if (fast_forward == FF_NO)
- die(_("You cannot combine --squash with --no-ff."));
- option_commit = 0;
- }
+ if (squash && fast_forward == FF_NO)
+ die(_("You cannot combine --squash with --no-ff."));
if (!argc) {
if (default_to_upstream)
@@ -1449,10 +1446,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* We are not doing octopus and not fast-forward. Need
* a real merge.
*/
- else if (!remoteheads->next && !common->next && option_commit) {
+ else if (!remoteheads->next && !common->next && option_commit && !squash) {
/*
* We are not doing octopus, not fast-forward, and have
- * only one common.
+ * only one common. And we do want to create a new commit.
*/
refresh_cache(REFRESH_QUIET);
if (allow_trivial && fast_forward != FF_ONLY) {
@@ -1535,7 +1532,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
ret = try_merge_strategy(use_strategies[i]->name,
common, remoteheads,
head_commit, head_arg);
- if (!option_commit && !ret) {
+ if ((!option_commit || squash) && !ret) {
merge_was_ok = 1;
/*
* This is necessary here just to avoid writing