git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Sergio via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Sergei Krivonos <sergeikrivonos@gmail.com>,
	Sergio <sergeikrivonos@gmail.com>
Subject: [PATCH 1/2] Make rebase.autostash default
Date: Thu, 18 Aug 2022 14:00:30 +0000	[thread overview]
Message-ID: <c48fbf984ea42e7c13d56db015dc63c2495f5f5f.1660831231.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1307.git.git.1660831231.gitgitgadget@gmail.com>

From: Sergio <sergeikrivonos@gmail.com>

Signed-off-by: Sergio <sergeikrivonos@gmail.com>
---
 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


  reply	other threads:[~2022-08-18 14:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18 14:00 [PATCH 0/2] Make rebase.autostash default Sergei Krivonos via GitGitGadget
2022-08-18 14:00 ` Sergio via GitGitGadget [this message]
2022-08-18 16:55   ` [PATCH 1/2] " brian m. carlson
2022-08-18 17:25   ` Junio C Hamano
2022-08-18 14:00 ` [PATCH 2/2] Add Eclipse project settings files to .gitignore Sergio via GitGitGadget
2022-08-18 17:00   ` brian m. carlson
2022-08-18 18:17     ` Junio C Hamano
2022-08-18 19:47       ` rsbecker
2022-08-18 17:31   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c48fbf984ea42e7c13d56db015dc63c2495f5f5f.1660831231.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sergeikrivonos@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).