On Mon, Jul 05 2021, Felipe Contreras wrote: > Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx> > --- > Documentation/git-update.txt | 4 ++++ > builtin/update.c | 20 +++++++++++++++++++- > t/t5563-update.sh | 15 +++++++++++++++ > 3 files changed, 38 insertions(+), 1 deletion(-) > > diff --git a/Documentation/git-update.txt b/Documentation/git-update.txt > index df778b7ef4..075653c6fd 100644 > --- a/Documentation/git-update.txt > +++ b/Documentation/git-update.txt > @@ -29,6 +29,10 @@ OPTIONS > --ff:: > Forces a fast-forward. > > +-m:: > +--merge:: > + Forces a merge. > + > SEE ALSO > -------- > linkgit:git-fetch[1], linkgit:git-fast-forward[1], > diff --git a/builtin/update.c b/builtin/update.c > index 34681fe21a..5946b383f5 100644 > --- a/builtin/update.c > +++ b/builtin/update.c > @@ -8,7 +8,8 @@ > #include "dir.h" > > enum update_mode_type { > - UPDATE_MODE_FAST_FORWARD = 0 > + UPDATE_MODE_FAST_FORWARD = 0, > + UPDATE_MODE_MERGE > }; > > static enum update_mode_type mode = UPDATE_MODE_FAST_FORWARD; > @@ -22,6 +23,9 @@ static struct option update_options[] = { > OPT_SET_INT_F('f', "ff", &mode, > N_("incorporate changes by fast-forwarding"), > UPDATE_MODE_FAST_FORWARD, PARSE_OPT_NONEG), > + OPT_SET_INT_F('m', "merge", &mode, > + N_("incorporate changes by merging"), > + UPDATE_MODE_MERGE, PARSE_OPT_NONEG), > > OPT_END() > }; > @@ -50,6 +54,18 @@ static int run_fast_forward(void) > return ret; > } > > +static int run_merge(void) > +{ > + int ret; > + struct strvec args = STRVEC_INIT; > + > + strvec_pushl(&args, "merge", "FETCH_HEAD", NULL); > + > + ret = run_command_v_opt(args.v, RUN_GIT_CMD); > + strvec_clear(&args); > + return ret; > +} > + > int cmd_update(int argc, const char **argv, const char *prefix) > { > if (!getenv("GIT_REFLOG_ACTION")) > @@ -68,6 +84,8 @@ int cmd_update(int argc, const char **argv, const char *prefix) > > if (mode == UPDATE_MODE_FAST_FORWARD) > return run_fast_forward(); > + if (mode == UPDATE_MODE_MERGE) > + return run_merge(); > > return 1; > } > diff --git a/t/t5563-update.sh b/t/t5563-update.sh > index 951df41ac4..833a5285da 100755 > --- a/t/t5563-update.sh > +++ b/t/t5563-update.sh > @@ -42,4 +42,19 @@ test_expect_success 'non-fast-forward update' ' > ) > ' > > +test_expect_success 'git update non-fast-forward with merge' ' > + test_when_finished "rm -rf test" && > + ( > + git clone . test && > + cd test && > + git checkout -b other master^ && > + >new && We usually indent the subshell... > + git add new && > + git commit -m new && And if we can use test_commit, less verbose.