git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Martin Ågren" <martin.agren@gmail.com>
To: git@vger.kernel.org
Cc: Dave Borowitz <dborowitz@google.com>,
	Junio C Hamano <gitster@pobox.com>,
	Stefan Beller <sbeller@google.com>
Subject: [PATCH 3/6] config: introduce git_parse_maybe_bool_text
Date: Mon,  7 Aug 2017 20:20:47 +0200	[thread overview]
Message-ID: <c244a7bfd521f99d79d0eae67395ff1dd6cd01d1.1502128418.git.martin.agren@gmail.com> (raw)
In-Reply-To: <cover.1502128418.git.martin.agren@gmail.com>

Commit 9a549d43 ("config.c: rename git_config_maybe_bool_text and export
it as git_parse_maybe_bool", 2015-08-19) intended git_parse_maybe_bool
to be a replacement for git_config_maybe_bool, which could then be
retired. That is not obvious from the commit message, but that is what
the background on the mailing list suggests [1].

However, git_{config,parse}_maybe_bool do not handle all input the same.
Before the rename, that was by design and there is a caller in config.c
which requires git_parse_maybe_bool to behave exactly as it does.

Prepare for the next patch by renaming git_parse_maybe_bool to ..._text
and reimplementing the first one as a simple call to the second one. Let
the existing users in config.c use ..._text, since it does what they
need.

[1] https://public-inbox.org/git/xmqq7fotd71o.fsf@gitster.dls.corp.google.com/

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 config.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/config.c b/config.c
index 231f9a750..7df57cec0 100644
--- a/config.c
+++ b/config.c
@@ -928,7 +928,7 @@ ssize_t git_config_ssize_t(const char *name, const char *value)
 	return ret;
 }
 
-int git_parse_maybe_bool(const char *value)
+static int git_parse_maybe_bool_text(const char *value)
 {
 	if (!value)
 		return 1;
@@ -945,9 +945,14 @@ int git_parse_maybe_bool(const char *value)
 	return -1;
 }
 
+int git_parse_maybe_bool(const char *value)
+{
+	return git_parse_maybe_bool_text(value);
+}
+
 int git_config_maybe_bool(const char *name, const char *value)
 {
-	int v = git_parse_maybe_bool(value);
+	int v = git_parse_maybe_bool_text(value);
 	if (0 <= v)
 		return v;
 	if (git_parse_int(value, &v))
@@ -957,7 +962,7 @@ int git_config_maybe_bool(const char *name, const char *value)
 
 int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
 {
-	int v = git_parse_maybe_bool(value);
+	int v = git_parse_maybe_bool_text(value);
 	if (0 <= v) {
 		*is_bool = 1;
 		return v;
-- 
2.14.0.5.g0f7b1ed27


  parent reply	other threads:[~2017-08-07 18:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-07 18:20 [PATCH 0/6] clean up parsing of maybe_bool Martin Ågren
2017-08-07 18:20 ` [PATCH 1/6] Doc/git-{push,send-pack}: correct --sign= to --signed= Martin Ågren
2017-08-07 18:20 ` [PATCH 2/6] t5334: document that git push --signed=1 does not work Martin Ågren
2017-08-07 20:25   ` Junio C Hamano
2017-08-07 18:20 ` Martin Ågren [this message]
2017-08-07 18:20 ` [PATCH 4/6] config: make git_{config,parse}_maybe_bool equivalent Martin Ågren
2017-08-07 18:20 ` [PATCH 5/6] treewide: deprecate git_config_maybe_bool, use git_parse_maybe_bool Martin Ågren
2017-08-07 18:20 ` [PATCH 6/6] parse_decoration_style: drop unused argument `var` Martin Ågren
2017-08-07 18:44 ` [PATCH 0/6] clean up parsing of maybe_bool Stefan Beller
2017-08-07 21:12   ` Junio C Hamano
2017-08-08  4:02     ` Martin Ågren
2017-08-08 17:04       ` Junio C Hamano
2017-08-08 17:21         ` Martin Ågren

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=c244a7bfd521f99d79d0eae67395ff1dd6cd01d1.1502128418.git.martin.agren@gmail.com \
    --to=martin.agren@gmail.com \
    --cc=dborowitz@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sbeller@google.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).