diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-04-26 14:25:19 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-26 14:34:58 -0700 |
commit | 8c3eaa0411f0e860b32da982eeb8e61b585d5a63 (patch) | |
tree | 4c32118746d492ee9c1acbbbc2cd8b6162e9ad19 | |
parent | ae599b1c18f689c39ccc87657d47a6ead9c61cb0 (diff) | |
download | git-jc/merge-impossible-no-commit.tar.gz |
merge: warn --no-commit merge when no new commit is createdjc/merge-impossible-no-commit
A user who uses "--no-commit" does so with the intention to record a
resulting merge after amending the merge result in the working tree.
But there is nothing to amend and record, if the same "git merge"
without "--no-commit" wouldn't have created a merge commit (there
are two cases: (1) the other branch is a descendant of the current
branch, (2) the other branch is an ancestor of the current branch).
The user would want to know that before doing further damange to his
history. When "merge --no-commit" fast-forwarded or succeeded with
"already up-to-date" or "fast-forward", give a warning message.
We may want to turn this into a die() after a transition period.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/merge.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/builtin/merge.c b/builtin/merge.c index f641751e4b..66c536d545 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1157,6 +1157,15 @@ static struct commit_list *collect_parents(struct commit *head_commit, return remoteheads; } +static void no_commit_impossible(const char *message) +{ + if (!option_commit) { + warning("%s\n%s", _(message), + _("--no-commit is impossible")); + warning(_("In future versions of Git, this will become an error.")); + } +} + int cmd_merge(int argc, const char **argv, const char *prefix) { unsigned char result_tree[20]; @@ -1403,6 +1412,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) * If head can reach all the merge then we are up to date. * but first the most common case of merging one remote. */ + no_commit_impossible(_("Already up-to-date")); finish_up_to_date("Already up-to-date."); goto done; } else if (fast_forward != FF_NO && !remoteheads->next && @@ -1412,6 +1422,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) struct strbuf msg = STRBUF_INIT; struct commit *commit; + no_commit_impossible(_("Fast-forward")); if (verbosity >= 0) { char from[GIT_SHA1_HEXSZ + 1], to[GIT_SHA1_HEXSZ + 1]; find_unique_abbrev_r(from, head_commit->object.oid.hash, @@ -1488,6 +1499,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) } } if (up_to_date) { + no_commit_impossible(_("Already up-to-date")); finish_up_to_date("Already up-to-date. Yeeah!"); goto done; } |