[RFC PATCH 17/35] update: add mode configuation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 Documentation/config.txt        |  2 ++
 Documentation/config/update.txt |  4 ++++
 builtin/update.c                | 26 ++++++++++++++++++++++++++
 3 files changed, 32 insertions(+)
 create mode 100644 Documentation/config/update.txt

diff --git a/Documentation/config.txt b/Documentation/config.txt
index fc4b49c0d4..998339e6fd 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -466,6 +466,8 @@ include::config/trace2.txt[]
 
 include::config/transfer.txt[]
 
+include::config/update.txt[]
+
 include::config/uploadarchive.txt[]
 
 include::config/uploadpack.txt[]
diff --git a/Documentation/config/update.txt b/Documentation/config/update.txt
new file mode 100644
index 0000000000..42a7fe1614
--- /dev/null
+++ b/Documentation/config/update.txt
@@ -0,0 +1,4 @@
+update.mode::
+	When `git update` is run, this determines the mode of operation,
+	possible values are 'fast-forward', 'merge', and 'rebase'. The default
+	is 'fast-forward'.
diff --git a/builtin/update.c b/builtin/update.c
index 989104421e..4a1b82a41d 100644
--- a/builtin/update.c
+++ b/builtin/update.c
@@ -5,9 +5,11 @@
 #include "builtin.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "config.h"
 #include "dir.h"
 
 enum update_mode_type {
+	UPDATE_MODE_INVALID = -1,
 	UPDATE_MODE_FAST_FORWARD = 0,
 	UPDATE_MODE_MERGE,
 	UPDATE_MODE_REBASE
@@ -34,6 +36,28 @@ static struct option update_options[] = {
 	OPT_END()
 };
 
+static enum update_mode_type update_mode_parse_value(const char *value)
+{
+	if (!strcmp(value, "fast-forward"))
+		return UPDATE_MODE_FAST_FORWARD;
+	if (!strcmp(value, "merge"))
+		return UPDATE_MODE_MERGE;
+	if (!strcmp(value, "rebase"))
+		return UPDATE_MODE_REBASE;
+
+	return UPDATE_MODE_INVALID;
+}
+
+static int git_update_config(const char *var, const char *value, void *cb)
+{
+	if (!strcmp(var, "update.mode")) {
+		mode = update_mode_parse_value(value);
+		return 0;
+	}
+
+	return git_default_config(var, value, cb);
+}
+
 static int run_fetch(void)
 {
 	struct strvec args = STRVEC_INIT;
@@ -87,6 +111,8 @@ int cmd_update(int argc, const char **argv, const char *prefix)
 	if (!getenv("GIT_REFLOG_ACTION"))
 		setenv("GIT_REFLOG_ACTION", "update", 0);
 
+	git_config(git_update_config, NULL);
+
 	argc = parse_options(argc, argv, prefix, update_options, update_usage, 0);
 
 	if (repo_read_index_unmerged(the_repository))
-- 
2.32.0.36.g70aac2b1aa




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux