From: Andreas Ericsson <ae@op5.se>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 1/2] config api: Add git_config_magic_int()
Date: Tue, 12 Feb 2008 09:21:21 +0100 [thread overview]
Message-ID: <47B15701.8040803@op5.se> (raw)
There are some values where git can reasonably guess at an
optimal value. For such occasions, this is a nifty addendum
to the config api, letting the caller specify a magic string
and a magic setting to return if the value of the variable
matches the magic string.
An example would be for threads, where 0 = auto is overly
voodoo-ish for some consumers, and typing "auto" is much
nicer and more immediately obvious.
Signed-off-by: Andreas Ericsson <ae@op5.se>
---
cache.h | 1 +
config.c | 9 +++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/cache.h b/cache.h
index 3867ba7..1b923ad 100644
--- a/cache.h
+++ b/cache.h
@@ -623,6 +623,7 @@ extern int git_config(config_fn_t fn);
extern int git_parse_long(const char *, long *);
extern int git_parse_ulong(const char *, unsigned long *);
extern int git_config_int(const char *, const char *);
+extern int git_config_magic_int(const char *, const char *, const char *, int);
extern unsigned long git_config_ulong(const char *, const char *);
extern int git_config_bool(const char *, const char *);
extern int git_config_set(const char *, const char *);
diff --git a/config.c b/config.c
index 3e72778..635d92b 100644
--- a/config.c
+++ b/config.c
@@ -288,6 +288,15 @@ int git_config_int(const char *name, const char *value)
return ret;
}
+int git_config_magic_int(const char *name, const char *value,
+ const char *magic_value, int magic_setting)
+{
+ if (value && !strcasecmp(value, magic_value))
+ return magic_setting;
+
+ return git_config_int(name, value);
+}
+
unsigned long git_config_ulong(const char *name, const char *value)
{
unsigned long ret;
--
1.5.4.rc5.11.g0eab8
next reply other threads:[~2008-02-12 8:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-12 8:21 Andreas Ericsson [this message]
2008-02-12 21:41 ` [PATCH 1/2] config api: Add git_config_magic_int() Junio C Hamano
2008-02-13 13:58 ` Andreas Ericsson
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47B15701.8040803@op5.se \
--to=ae@op5.se \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
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 NNTP newsgroup(s).