Skip to content

Commit 1fdbfc4

Browse files
committed
Merge branch 'jc/merge-drop-old-syntax'
Stop supporting "git merge <message> HEAD <commit>" syntax that has been deprecated since October 2007, and issues a deprecation warning message since v2.5.0. * jc/merge-drop-old-syntax: merge: drop 'git merge <message> HEAD <commit>' syntax
2 parents e1104a5 + b439165 commit 1fdbfc4

File tree

2 files changed

+10
-56
lines changed

2 files changed

+10
-56
lines changed

Documentation/git-merge.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ SYNOPSIS
1313
[-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
1414
[--[no-]allow-unrelated-histories]
1515
[--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
16-
'git merge' <msg> HEAD <commit>...
1716
'git merge' --abort
1817
'git merge' --continue
1918

@@ -46,11 +45,7 @@ a log message from the user describing the changes.
4645
D---E---F---G---H master
4746
------------
4847

49-
The second syntax (<msg> `HEAD` <commit>...) is supported for
50-
historical reasons. Do not use it from the command line or in
51-
new scripts. It is the same as `git merge -m <msg> <commit>...`.
52-
53-
The third syntax ("`git merge --abort`") can only be run after the
48+
The second syntax ("`git merge --abort`") can only be run after the
5449
merge has resulted in conflicts. 'git merge --abort' will abort the
5550
merge process and try to reconstruct the pre-merge state. However,
5651
if there were uncommitted changes when the merge started (and

builtin/merge.c

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ struct strategy {
4444

4545
static const char * const builtin_merge_usage[] = {
4646
N_("git merge [<options>] [<commit>...]"),
47-
N_("git merge [<options>] <msg> HEAD <commit>"),
4847
N_("git merge --abort"),
4948
N_("git merge --continue"),
5049
NULL
@@ -634,9 +633,10 @@ static void write_tree_trivial(struct object_id *oid)
634633

635634
static int try_merge_strategy(const char *strategy, struct commit_list *common,
636635
struct commit_list *remoteheads,
637-
struct commit *head, const char *head_arg)
636+
struct commit *head)
638637
{
639638
static struct lock_file lock;
639+
const char *head_arg = "HEAD";
640640

641641
hold_locked_index(&lock, LOCK_DIE_ON_ERROR);
642642
refresh_cache(REFRESH_QUIET);
@@ -853,24 +853,6 @@ static int suggest_conflicts(void)
853853
return 1;
854854
}
855855

856-
static struct commit *is_old_style_invocation(int argc, const char **argv,
857-
const struct object_id *head)
858-
{
859-
struct commit *second_token = NULL;
860-
if (argc > 2) {
861-
struct object_id second_oid;
862-
863-
if (get_oid(argv[1], &second_oid))
864-
return NULL;
865-
second_token = lookup_commit_reference_gently(second_oid.hash, 0);
866-
if (!second_token)
867-
die(_("'%s' is not a commit"), argv[1]);
868-
if (oidcmp(&second_token->object.oid, head))
869-
return NULL;
870-
}
871-
return second_token;
872-
}
873-
874856
static int evaluate_result(void)
875857
{
876858
int cnt = 0;
@@ -1120,7 +1102,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
11201102
struct object_id result_tree, stash, head_oid;
11211103
struct commit *head_commit;
11221104
struct strbuf buf = STRBUF_INIT;
1123-
const char *head_arg;
11241105
int i, ret = 0, head_subsumed;
11251106
int best_cnt = -1, merge_was_ok = 0, automerge_was_ok = 0;
11261107
struct commit_list *common = NULL;
@@ -1260,34 +1241,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
12601241
}
12611242

12621243
/*
1263-
* This could be traditional "merge <msg> HEAD <commit>..." and
1264-
* the way we can tell it is to see if the second token is HEAD,
1265-
* but some people might have misused the interface and used a
1266-
* commit-ish that is the same as HEAD there instead.
1267-
* Traditional format never would have "-m" so it is an
1268-
* additional safety measure to check for it.
1244+
* All the rest are the commits being merged; prepare
1245+
* the standard merge summary message to be appended
1246+
* to the given message.
12691247
*/
1270-
if (!have_message &&
1271-
is_old_style_invocation(argc, argv, &head_commit->object.oid)) {
1272-
warning("old-style 'git merge <msg> HEAD <commit>' is deprecated.");
1273-
strbuf_addstr(&merge_msg, argv[0]);
1274-
head_arg = argv[1];
1275-
argv += 2;
1276-
argc -= 2;
1277-
remoteheads = collect_parents(head_commit, &head_subsumed,
1278-
argc, argv, NULL);
1279-
} else {
1280-
/* We are invoked directly as the first-class UI. */
1281-
head_arg = "HEAD";
1282-
1283-
/*
1284-
* All the rest are the commits being merged; prepare
1285-
* the standard merge summary message to be appended
1286-
* to the given message.
1287-
*/
1288-
remoteheads = collect_parents(head_commit, &head_subsumed,
1289-
argc, argv, &merge_msg);
1290-
}
1248+
remoteheads = collect_parents(head_commit, &head_subsumed,
1249+
argc, argv, &merge_msg);
12911250

12921251
if (!head_commit || !argc)
12931252
usage_with_options(builtin_merge_usage,
@@ -1513,7 +1472,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
15131472

15141473
ret = try_merge_strategy(use_strategies[i]->name,
15151474
common, remoteheads,
1516-
head_commit, head_arg);
1475+
head_commit);
15171476
if (!option_commit && !ret) {
15181477
merge_was_ok = 1;
15191478
/*
@@ -1583,7 +1542,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
15831542
printf(_("Using the %s to prepare resolving by hand.\n"),
15841543
best_strategy);
15851544
try_merge_strategy(best_strategy, common, remoteheads,
1586-
head_commit, head_arg);
1545+
head_commit);
15871546
}
15881547

15891548
if (squash)

0 commit comments

Comments
 (0)