From: Tanay Abhra <tanayabh@gmail.com>
To: git@vger.kernel.org
Cc: Tanay Abhra <tanayabh@gmail.com>,
Ramkumar Ramachandra <artagnon@gmail.com>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v13 0/2] git config cache & special querying api utilizing the cache
Date: Mon, 28 Jul 2014 03:10:37 -0700 [thread overview]
Message-ID: <1406542239-17024-1-git-send-email-tanayabh@gmail.com> (raw)
[v13]: v12 was rejected because of redundant implementation of the new functions,
hope this one is okay.
I am attaching the v13 with two new functions git_configset_get_string() &
git_configset_get_string_const().
Diff between v11 and v13 is appended below for easy review.
v11 can be seen at [1].
[1]:: http://thread.gmane.org/gmane.comp.version-control.git/253862/
Tanay Abhra (2):
add `config_set` API for caching config-like files
test-config: add tests for the config_set API
.gitignore | 1 +
Documentation/technical/api-config.txt | 142 +++++++++++++++++
Makefile | 1 +
cache.h | 32 ++++
config.c | 274 +++++++++++++++++++++++++++++++++
setup.c | 9 ++
t/t1308-config-set.sh | 200 ++++++++++++++++++++++++
test-config.c | 142 +++++++++++++++++
8 files changed, 801 insertions(+)
create mode 100755 t/t1308-config-set.sh
create mode 100644 test-config.c
--
1.9.0.GIT
-- 8< --
t_config_get_string(const char *key, const char **dest)`::
+`int git_config_get_string_const(const char *key, const char **dest)`::
Allocates and copies the retrieved string into the `dest` parameter for
the configuration variable `key`; if NULL string is given, prints an
error message and returns -1. When the configuration variable `key` is
not found, returns 1 without touching `dest`.
+`int git_config_get_string(const char *key, char **dest)`::
+
+ Similar to `git_config_get_string_const`, except that retrieved value
+ copied into the `dest` parameter is a mutable string.
+
`int git_config_get_pathname(const char *key, const char **dest)`::
Similar to `git_config_get_string`, but expands `~` or `~user` into
diff --git a/cache.h b/cache.h
index 2f63fd1..7292aef 100644
--- a/cache.h
+++ b/cache.h
@@ -1361,7 +1361,8 @@ extern int git_configset_add_file(struct config_set *cs, const char *filename);
extern int git_configset_get_value(struct config_set *cs, const char *key, const char **value);
extern const struct string_list *git_configset_get_value_multi(struct config_set *cs, const char *key);
extern void git_configset_clear(struct config_set *cs);
-extern int git_configset_get_string(struct config_set *cs, const char *key, const char **dest);
+extern int git_configset_get_string_const(struct config_set *cs, const char *key, const char **dest);
+extern int git_configset_get_string(struct config_set *cs, const char *key, char **dest);
extern int git_configset_get_int(struct config_set *cs, const char *key, int *dest);
extern int git_configset_get_ulong(struct config_set *cs, const char *key, unsigned long *dest);
extern int git_configset_get_bool(struct config_set *cs, const char *key, int *dest);
@@ -1373,7 +1374,8 @@ extern int git_config_get_value(const char *key, const char **value);
extern const struct string_list *git_config_get_value_multi(const char *key);
extern void git_config_clear(void);
extern void git_config_iter(config_fn_t fn, void *data);
-extern int git_config_get_string(const char *key, const char **dest);
+extern int git_config_get_string_const(const char *key, const char **dest);
+extern int git_config_get_string(const char *key, char **dest);
extern int git_config_get_int(const char *key, int *dest);
extern int git_config_get_ulong(const char *key, unsigned long *dest);
extern int git_config_get_bool(const char *key, int *dest);
diff --git a/config.c b/config.c
index 22971e9..d3ad661 100644
--- a/config.c
+++ b/config.c
@@ -1332,7 +1332,7 @@ const struct string_list *git_configset_get_value_multi(struct config_set *cs, c
return e ? &e->value_list : NULL;
}
-int git_configset_get_string(struct config_set *cs, const char *key, const char **dest)
+int git_configset_get_string_const(struct config_set *cs, const char *key, const char **dest)
{
const char *value;
if (!git_configset_get_value(cs, key, &value))
@@ -1341,6 +1341,11 @@ int git_configset_get_string(struct config_set *cs, const char *key, const char
return 1;
}
+int git_configset_get_string(struct config_set *cs, const char *key, char **dest)
+{
+ return git_configset_get_string_const(cs, key, (const char **)dest);
+}
+
int git_configset_get_int(struct config_set *cs, const char *key, int *dest)
{
const char *value;
@@ -1430,10 +1435,16 @@ const struct string_list *git_config_get_value_multi(const char *key)
return git_configset_get_value_multi(&the_config_set, key);
}
-int git_config_get_string(const char *key, const char **dest)
+int git_config_get_string_const(const char *key, const char **dest)
+{
+ git_config_check_init();
+ return git_configset_get_string_const(&the_config_set, key, dest);
+}
+
+int git_config_get_string(const char *key, char **dest)
{
git_config_check_init();
- return git_configset_get_string(&the_config_set, key, dest);
+ return git_config_get_string_const(key, (const char **)dest);
}
int git_config_get_int(const char *key, int *dest)
-- 8< --
next reply other threads:[~2014-07-28 10:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-28 10:10 Tanay Abhra [this message]
2014-07-28 10:10 ` [PATCH v13 1/2] add `config_set` API for caching config-like files Tanay Abhra
2014-07-28 10:10 ` [PATCH v13 2/2] test-config: add tests for the config_set API Tanay Abhra
2014-07-28 11:10 ` [PATCH v13 0/2] git config cache & special querying api utilizing the cache Matthieu Moy
2014-07-29 21:37 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1406542239-17024-1-git-send-email-tanayabh@gmail.com \
--to=tanayabh@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=artagnon@gmail.com \
--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).