[PATCH 1/2] Make rebase.autostash default

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

 



From: Sergio <sergeikrivonos@xxxxxxxxx>

Signed-off-by: Sergio <sergeikrivonos@xxxxxxxxx>
---
 Documentation/config/rebase.txt | 2 +-
 builtin/pull.c                  | 2 +-
 config.c                        | 8 ++++++++
 config.h                        | 8 ++++++++
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Documentation/config/rebase.txt b/Documentation/config/rebase.txt
index f19bd0e0407..bc952327140 100644
--- a/Documentation/config/rebase.txt
+++ b/Documentation/config/rebase.txt
@@ -19,7 +19,7 @@ rebase.autoStash::
 	successful rebase might result in non-trivial conflicts.
 	This option can be overridden by the `--no-autostash` and
 	`--autostash` options of linkgit:git-rebase[1].
-	Defaults to false.
+	Defaults to true.
 
 rebase.updateRefs::
 	If set to true enable `--update-refs` option by default.
diff --git a/builtin/pull.c b/builtin/pull.c
index 403a24d7ca6..333d6a232a7 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -362,7 +362,7 @@ static int git_pull_config(const char *var, const char *value, void *cb)
 	int status;
 
 	if (!strcmp(var, "rebase.autostash")) {
-		config_autostash = git_config_bool(var, value);
+		config_autostash = git_config_bool_or_default(var, value, 1);
 		return 0;
 	} else if (!strcmp(var, "submodule.recurse")) {
 		recurse_submodules = git_config_bool(var, value) ?
diff --git a/config.c b/config.c
index e8ebef77d5c..c4f6da3547e 100644
--- a/config.c
+++ b/config.c
@@ -1437,6 +1437,14 @@ int git_config_bool(const char *name, const char *value)
 	return v;
 }
 
+int git_config_bool_or_default(const char *name, const char *value, int default_value)
+{
+	int v = git_parse_maybe_bool(value);
+	if (v < 0)
+		v = default_value;
+	return v;
+}
+
 int git_config_string(const char **dest, const char *var, const char *value)
 {
 	if (!value)
diff --git a/config.h b/config.h
index ca994d77147..d236bb0a326 100644
--- a/config.h
+++ b/config.h
@@ -242,6 +242,14 @@ int git_config_bool_or_int(const char *, const char *, int *);
  */
 int git_config_bool(const char *, const char *);
 
+/**
+ * Parse a string into a boolean value, respecting keywords like "true" and
+ * "false". Integer values are converted into true/false values (when they
+ * are non-zero or zero, respectively). Other values results in default. If
+ * parsing is successful, the return value is the result.
+ */
+int git_config_bool_or_default(const char *, const char *, int);
+
 /**
  * Allocates and copies the value string into the `dest` parameter; if no
  * string is given, prints an error message and returns -1.
-- 
gitgitgadget




[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