summaryrefslogtreecommitdiff
path: root/builtin/merge.c
diff options
context:
space:
mode:
authorVishal Verma <vishal@stellar.sh>2019-05-24 18:36:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-05-28 18:53:11 (GMT)
commit1d14d0c9949c02260fe4f8b3a54a1b5c605823a2 (patch)
treeddafb00ad119393fe27fd594541f757a0fb46270 /builtin/merge.c
parentaeb582a98374c094361cba1bd756dc6307432c42 (diff)
downloadgit-1d14d0c9949c02260fe4f8b3a54a1b5c605823a2.zip
git-1d14d0c9949c02260fe4f8b3a54a1b5c605823a2.tar.gz
git-1d14d0c9949c02260fe4f8b3a54a1b5c605823a2.tar.bz2
merge: refuse --commit with --squash
Convert option_commit to tristate, representing the states of 'default/untouched', 'enabled-by-cli', 'disabled-by-cli'. With this in place, check whether option_commit was enabled by cli when squashing a merge. If so, error out, as this is not supported. Previously, when --squash was supplied, 'option_commit' was silently dropped. This could have been surprising to a user who tried to override the no-commit behavior of squash using --commit explicitly. Add a note to the --squash option for git-merge to clarify the incompatibility, and add a test case to t7600-merge.sh Cc: Junio C Hamano <gitster@pobox.com> Cc: Rafael Ascensão <rafa.almas@gmail.com> Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Vishal Verma <vishal@stellar.sh> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/merge.c')
-rw-r--r--builtin/merge.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index e47d77b..18b9091 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -57,7 +57,7 @@ static const char * const builtin_merge_usage[] = {
};
static int show_diffstat = 1, shortlog_len = -1, squash;
-static int option_commit = 1;
+static int option_commit = -1;
static int option_edit = -1;
static int allow_trivial = 1, have_message, verify_signatures;
static int overwrite_ignore = 1;
@@ -1304,9 +1304,19 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
if (squash) {
if (fast_forward == FF_NO)
die(_("You cannot combine --squash with --no-ff."));
+ if (option_commit > 0)
+ die(_("You cannot combine --squash with --commit."));
+ /*
+ * squash can now silently disable option_commit - this is not
+ * a problem as it is only overriding the default, not a user
+ * supplied option.
+ */
option_commit = 0;
}
+ if (option_commit < 0)
+ option_commit = 1;
+
if (!argc) {
if (default_to_upstream)
argc = setup_with_upstream(&argv);