Skip to content

Commit b439165

Browse files
committed
merge: drop 'git merge <message> HEAD <commit>' syntax
And then if we and our users survived the previous "start warning if the old syntax is used" patch for a few years, we could apply this to actually drop the support for the ancient syntax. Signed-off-by: Junio C Hamano <[email protected]>
1 parent d45366e commit b439165

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
@@ -12,7 +12,6 @@ SYNOPSIS
1212
'git merge' [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
1313
[-s <strategy>] [-X <strategy-option>] [-S[<key-id>]]
1414
[--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
15-
'git merge' <msg> HEAD <commit>...
1615
'git merge' --abort
1716

1817
DESCRIPTION
@@ -44,11 +43,7 @@ a log message from the user describing the changes.
4443
D---E---F---G---H master
4544
------------
4645

47-
The second syntax (<msg> `HEAD` <commit>...) is supported for
48-
historical reasons. Do not use it from the command line or in
49-
new scripts. It is the same as `git merge -m <msg> <commit>...`.
50-
51-
The third syntax ("`git merge --abort`") can only be run after the
46+
The second syntax ("`git merge --abort`") can only be run after the
5247
merge has resulted in conflicts. 'git merge --abort' will abort the
5348
merge process and try to reconstruct the pre-merge state. However,
5449
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
@@ -42,7 +42,6 @@ struct strategy {
4242

4343
static const char * const builtin_merge_usage[] = {
4444
N_("git merge [options] [<commit>...]"),
45-
N_("git merge [options] <msg> HEAD <commit>"),
4645
N_("git merge --abort"),
4746
NULL
4847
};
@@ -633,9 +632,10 @@ static void write_tree_trivial(unsigned char *sha1)
633632

634633
static int try_merge_strategy(const char *strategy, struct commit_list *common,
635634
struct commit_list *remoteheads,
636-
struct commit *head, const char *head_arg)
635+
struct commit *head)
637636
{
638637
static struct lock_file lock;
638+
const char *head_arg = "HEAD";
639639

640640
hold_locked_index(&lock, 1);
641641
refresh_cache(REFRESH_QUIET);
@@ -887,24 +887,6 @@ static int suggest_conflicts(int renormalizing)
887887
return 1;
888888
}
889889

890-
static struct commit *is_old_style_invocation(int argc, const char **argv,
891-
const unsigned char *head)
892-
{
893-
struct commit *second_token = NULL;
894-
if (argc > 2) {
895-
unsigned char second_sha1[20];
896-
897-
if (get_sha1(argv[1], second_sha1))
898-
return NULL;
899-
second_token = lookup_commit_reference_gently(second_sha1, 0);
900-
if (!second_token)
901-
die(_("'%s' is not a commit"), argv[1]);
902-
if (hashcmp(second_token->object.sha1, head))
903-
return NULL;
904-
}
905-
return second_token;
906-
}
907-
908890
static int evaluate_result(void)
909891
{
910892
int cnt = 0;
@@ -1172,7 +1154,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
11721154
unsigned char head_sha1[20];
11731155
struct commit *head_commit;
11741156
struct strbuf buf = STRBUF_INIT;
1175-
const char *head_arg;
11761157
int flag, i, ret = 0, head_subsumed;
11771158
int best_cnt = -1, merge_was_ok = 0, automerge_was_ok = 0;
11781159
struct commit_list *common = NULL;
@@ -1290,34 +1271,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
12901271
}
12911272

12921273
/*
1293-
* This could be traditional "merge <msg> HEAD <commit>..." and
1294-
* the way we can tell it is to see if the second token is HEAD,
1295-
* but some people might have misused the interface and used a
1296-
* commit-ish that is the same as HEAD there instead.
1297-
* Traditional format never would have "-m" so it is an
1298-
* additional safety measure to check for it.
1274+
* All the rest are the commits being merged; prepare
1275+
* the standard merge summary message to be appended
1276+
* to the given message.
12991277
*/
1300-
if (!have_message &&
1301-
is_old_style_invocation(argc, argv, head_commit->object.sha1)) {
1302-
warning("old-style 'git merge <msg> HEAD <commit>' is deprecated.");
1303-
strbuf_addstr(&merge_msg, argv[0]);
1304-
head_arg = argv[1];
1305-
argv += 2;
1306-
argc -= 2;
1307-
remoteheads = collect_parents(head_commit, &head_subsumed,
1308-
argc, argv, NULL);
1309-
} else {
1310-
/* We are invoked directly as the first-class UI. */
1311-
head_arg = "HEAD";
1312-
1313-
/*
1314-
* All the rest are the commits being merged; prepare
1315-
* the standard merge summary message to be appended
1316-
* to the given message.
1317-
*/
1318-
remoteheads = collect_parents(head_commit, &head_subsumed,
1319-
argc, argv, &merge_msg);
1320-
}
1278+
remoteheads = collect_parents(head_commit, &head_subsumed,
1279+
argc, argv, &merge_msg);
13211280

13221281
if (!head_commit || !argc)
13231282
usage_with_options(builtin_merge_usage,
@@ -1542,7 +1501,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
15421501

15431502
ret = try_merge_strategy(use_strategies[i]->name,
15441503
common, remoteheads,
1545-
head_commit, head_arg);
1504+
head_commit);
15461505
if (!option_commit && !ret) {
15471506
merge_was_ok = 1;
15481507
/*
@@ -1612,7 +1571,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
16121571
printf(_("Using the %s to prepare resolving by hand.\n"),
16131572
best_strategy);
16141573
try_merge_strategy(best_strategy, common, remoteheads,
1615-
head_commit, head_arg);
1574+
head_commit);
16161575
}
16171576

16181577
if (squash)

0 commit comments

Comments
 (0)