зеркало из https://github.com/microsoft/git.git
merge: allow reading the merge commit message from a file
This is consistent with `git commit` which, like `git merge`, supports passing the commit message via `-m <msg>` and, unlike `git merge` before this patch, via `-F <file>`. It is useful to allow this for scripted use, or for the upcoming patch to allow (re-)creating octopus merges in `git rebase --rebase-merges`. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
e3331758f1
Коммит
920f22e6bc
|
@ -12,7 +12,7 @@ SYNOPSIS
|
|||
'git merge' [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
|
||||
[-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
|
||||
[--[no-]allow-unrelated-histories]
|
||||
[--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
|
||||
[--[no-]rerere-autoupdate] [-m <msg>] [-F <file>] [<commit>...]
|
||||
'git merge' --abort
|
||||
'git merge' --continue
|
||||
|
||||
|
@ -75,6 +75,14 @@ The 'git fmt-merge-msg' command can be
|
|||
used to give a good default for automated 'git merge'
|
||||
invocations. The automated message can include the branch description.
|
||||
|
||||
-F <file>::
|
||||
--file=<file>::
|
||||
Read the commit message to be used for the merge commit (in
|
||||
case one is created).
|
||||
+
|
||||
If `--log` is specified, a shortlog of the commits being merged
|
||||
will be appended to the specified message.
|
||||
|
||||
--[no-]rerere-autoupdate::
|
||||
Allow the rerere mechanism to update the index with the
|
||||
result of auto-conflict resolution if possible.
|
||||
|
|
|
@ -111,6 +111,35 @@ static int option_parse_message(const struct option *opt,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int option_read_message(struct parse_opt_ctx_t *ctx,
|
||||
const struct option *opt, int unset)
|
||||
{
|
||||
struct strbuf *buf = opt->value;
|
||||
const char *arg;
|
||||
|
||||
if (unset)
|
||||
BUG("-F cannot be negated");
|
||||
|
||||
if (ctx->opt) {
|
||||
arg = ctx->opt;
|
||||
ctx->opt = NULL;
|
||||
} else if (ctx->argc > 1) {
|
||||
ctx->argc--;
|
||||
arg = *++ctx->argv;
|
||||
} else
|
||||
return opterror(opt, "requires a value", 0);
|
||||
|
||||
if (buf->len)
|
||||
strbuf_addch(buf, '\n');
|
||||
if (ctx->prefix && !is_absolute_path(arg))
|
||||
arg = prefix_filename(ctx->prefix, arg);
|
||||
if (strbuf_read_file(buf, arg, 0) < 0)
|
||||
return error(_("could not read file '%s'"), arg);
|
||||
have_message = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct strategy *get_strategy(const char *name)
|
||||
{
|
||||
int i;
|
||||
|
@ -228,6 +257,9 @@ static struct option builtin_merge_options[] = {
|
|||
OPT_CALLBACK('m', "message", &merge_msg, N_("message"),
|
||||
N_("merge commit message (for a non-fast-forward merge)"),
|
||||
option_parse_message),
|
||||
{ OPTION_LOWLEVEL_CALLBACK, 'F', "file", &merge_msg, N_("path"),
|
||||
N_("read message from file"), PARSE_OPT_NONEG,
|
||||
(parse_opt_cb *) option_read_message },
|
||||
OPT__VERBOSITY(&verbosity),
|
||||
OPT_BOOL(0, "abort", &abort_current_merge,
|
||||
N_("abort the current in-progress merge")),
|
||||
|
|
Загрузка…
Ссылка в новой задаче