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 <gitster@pobox.com>
This commit is contained in:
@ -12,7 +12,6 @@ SYNOPSIS
|
|||||||
'git merge' [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
|
'git merge' [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
|
||||||
[-s <strategy>] [-X <strategy-option>] [-S[<key-id>]]
|
[-s <strategy>] [-X <strategy-option>] [-S[<key-id>]]
|
||||||
[--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
|
[--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
|
||||||
'git merge' <msg> HEAD <commit>...
|
|
||||||
'git merge' --abort
|
'git merge' --abort
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
@ -44,11 +43,7 @@ a log message from the user describing the changes.
|
|||||||
D---E---F---G---H master
|
D---E---F---G---H master
|
||||||
------------
|
------------
|
||||||
|
|
||||||
The second syntax (<msg> `HEAD` <commit>...) is supported for
|
The second syntax ("`git merge --abort`") can only be run after the
|
||||||
historical reasons. Do not use it from the command line or in
|
|
||||||
new scripts. It is the same as `git merge -m <msg> <commit>...`.
|
|
||||||
|
|
||||||
The third syntax ("`git merge --abort`") can only be run after the
|
|
||||||
merge has resulted in conflicts. 'git merge --abort' will abort the
|
merge has resulted in conflicts. 'git merge --abort' will abort the
|
||||||
merge process and try to reconstruct the pre-merge state. However,
|
merge process and try to reconstruct the pre-merge state. However,
|
||||||
if there were uncommitted changes when the merge started (and
|
if there were uncommitted changes when the merge started (and
|
||||||
|
@ -42,7 +42,6 @@ struct strategy {
|
|||||||
|
|
||||||
static const char * const builtin_merge_usage[] = {
|
static const char * const builtin_merge_usage[] = {
|
||||||
N_("git merge [options] [<commit>...]"),
|
N_("git merge [options] [<commit>...]"),
|
||||||
N_("git merge [options] <msg> HEAD <commit>"),
|
|
||||||
N_("git merge --abort"),
|
N_("git merge --abort"),
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
@ -633,9 +632,10 @@ static void write_tree_trivial(unsigned char *sha1)
|
|||||||
|
|
||||||
static int try_merge_strategy(const char *strategy, struct commit_list *common,
|
static int try_merge_strategy(const char *strategy, struct commit_list *common,
|
||||||
struct commit_list *remoteheads,
|
struct commit_list *remoteheads,
|
||||||
struct commit *head, const char *head_arg)
|
struct commit *head)
|
||||||
{
|
{
|
||||||
static struct lock_file lock;
|
static struct lock_file lock;
|
||||||
|
const char *head_arg = "HEAD";
|
||||||
|
|
||||||
hold_locked_index(&lock, 1);
|
hold_locked_index(&lock, 1);
|
||||||
refresh_cache(REFRESH_QUIET);
|
refresh_cache(REFRESH_QUIET);
|
||||||
@ -887,24 +887,6 @@ static int suggest_conflicts(int renormalizing)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct commit *is_old_style_invocation(int argc, const char **argv,
|
|
||||||
const unsigned char *head)
|
|
||||||
{
|
|
||||||
struct commit *second_token = NULL;
|
|
||||||
if (argc > 2) {
|
|
||||||
unsigned char second_sha1[20];
|
|
||||||
|
|
||||||
if (get_sha1(argv[1], second_sha1))
|
|
||||||
return NULL;
|
|
||||||
second_token = lookup_commit_reference_gently(second_sha1, 0);
|
|
||||||
if (!second_token)
|
|
||||||
die(_("'%s' is not a commit"), argv[1]);
|
|
||||||
if (hashcmp(second_token->object.sha1, head))
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return second_token;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int evaluate_result(void)
|
static int evaluate_result(void)
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
@ -1172,7 +1154,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||||||
unsigned char head_sha1[20];
|
unsigned char head_sha1[20];
|
||||||
struct commit *head_commit;
|
struct commit *head_commit;
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
const char *head_arg;
|
|
||||||
int flag, i, ret = 0, head_subsumed;
|
int flag, i, ret = 0, head_subsumed;
|
||||||
int best_cnt = -1, merge_was_ok = 0, automerge_was_ok = 0;
|
int best_cnt = -1, merge_was_ok = 0, automerge_was_ok = 0;
|
||||||
struct commit_list *common = NULL;
|
struct commit_list *common = NULL;
|
||||||
@ -1290,34 +1271,12 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This could be traditional "merge <msg> HEAD <commit>..." and
|
* All the rest are the commits being merged; prepare
|
||||||
* the way we can tell it is to see if the second token is HEAD,
|
* the standard merge summary message to be appended
|
||||||
* but some people might have misused the interface and used a
|
* to the given message.
|
||||||
* commit-ish that is the same as HEAD there instead.
|
|
||||||
* Traditional format never would have "-m" so it is an
|
|
||||||
* additional safety measure to check for it.
|
|
||||||
*/
|
*/
|
||||||
if (!have_message &&
|
remoteheads = collect_parents(head_commit, &head_subsumed,
|
||||||
is_old_style_invocation(argc, argv, head_commit->object.sha1)) {
|
argc, argv, &merge_msg);
|
||||||
warning("old-style 'git merge <msg> HEAD <commit>' is deprecated.");
|
|
||||||
strbuf_addstr(&merge_msg, argv[0]);
|
|
||||||
head_arg = argv[1];
|
|
||||||
argv += 2;
|
|
||||||
argc -= 2;
|
|
||||||
remoteheads = collect_parents(head_commit, &head_subsumed,
|
|
||||||
argc, argv, NULL);
|
|
||||||
} else {
|
|
||||||
/* We are invoked directly as the first-class UI. */
|
|
||||||
head_arg = "HEAD";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* All the rest are the commits being merged; prepare
|
|
||||||
* the standard merge summary message to be appended
|
|
||||||
* to the given message.
|
|
||||||
*/
|
|
||||||
remoteheads = collect_parents(head_commit, &head_subsumed,
|
|
||||||
argc, argv, &merge_msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!head_commit || !argc)
|
if (!head_commit || !argc)
|
||||||
usage_with_options(builtin_merge_usage,
|
usage_with_options(builtin_merge_usage,
|
||||||
@ -1542,7 +1501,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
ret = try_merge_strategy(use_strategies[i]->name,
|
ret = try_merge_strategy(use_strategies[i]->name,
|
||||||
common, remoteheads,
|
common, remoteheads,
|
||||||
head_commit, head_arg);
|
head_commit);
|
||||||
if (!option_commit && !ret) {
|
if (!option_commit && !ret) {
|
||||||
merge_was_ok = 1;
|
merge_was_ok = 1;
|
||||||
/*
|
/*
|
||||||
@ -1612,7 +1571,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||||||
printf(_("Using the %s to prepare resolving by hand.\n"),
|
printf(_("Using the %s to prepare resolving by hand.\n"),
|
||||||
best_strategy);
|
best_strategy);
|
||||||
try_merge_strategy(best_strategy, common, remoteheads,
|
try_merge_strategy(best_strategy, common, remoteheads,
|
||||||
head_commit, head_arg);
|
head_commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (squash)
|
if (squash)
|
||||||
|
Reference in New Issue
Block a user