[RFC PATCH 10/35] update: add --ff option
STALE1917d
From: Felipe Contreras <hidden>
Date: 2021-07-05 12:32:32
Subsystem:
documentation, the rest · Maintainers:
Jonathan Corbet, Linus Torvalds
This is the default, it doesn't change anything. Signed-off-by: Felipe Contreras <redacted> --- Documentation/git-update.txt | 9 ++++++++- builtin/update.c | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-update.txt b/Documentation/git-update.txt
index 54c49c5d12..df778b7ef4 100644
--- a/Documentation/git-update.txt
+++ b/Documentation/git-update.txt@@ -8,7 +8,7 @@ git-update - Update the current branch to the latest remote SYNOPSIS -------- [verse] -'git update' +'git update' [<options>] DESCRIPTION -----------
@@ -22,6 +22,13 @@ the update operation is straight-forward, but if you do a further `git merge` or THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOUR MAY CHANGE. +OPTIONS +------- + +-f:: +--ff:: + Forces a fast-forward. + SEE ALSO -------- linkgit:git-fetch[1], linkgit:git-fast-forward[1],
diff --git a/builtin/update.c b/builtin/update.c
index 1a69896aa8..34681fe21a 100644
--- a/builtin/update.c
+++ b/builtin/update.c@@ -7,12 +7,22 @@ #include "run-command.h" #include "dir.h" +enum update_mode_type { + UPDATE_MODE_FAST_FORWARD = 0 +}; + +static enum update_mode_type mode = UPDATE_MODE_FAST_FORWARD; + static const char * const update_usage[] = { - N_("git update"), + N_("git update [<options>]"), NULL }; 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_END() };
@@ -56,5 +66,8 @@ int cmd_update(int argc, const char **argv, const char *prefix) if (run_fetch()) return 1; - return run_fast_forward(); + if (mode == UPDATE_MODE_FAST_FORWARD) + return run_fast_forward(); + + return 1; }
--
2.32.0.36.g70aac2b1aa