summaryrefslogtreecommitdiff
path: root/alias.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2008-02-24 22:17:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-02-25 02:31:49 (GMT)
commit94351118c0a820002b093598e7fac5bdf3c0291f (patch)
tree9409a429659a6a244e9f9bd123070a0ef1be479d /alias.c
parent41eb33bd0cbecf1b441ada91ab186ee49fb086cc (diff)
downloadgit-94351118c0a820002b093598e7fac5bdf3c0291f.zip
git-94351118c0a820002b093598e7fac5bdf3c0291f.tar.gz
git-94351118c0a820002b093598e7fac5bdf3c0291f.tar.bz2
make alias lookup a public, procedural function
This converts git_config_alias to the public alias_lookup function. Because of the nature of our config parser, we still have to rely on setting static data. However, that interface is wrapped so that you can just say value = alias_lookup(key); Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'alias.c')
-rw-r--r--alias.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/alias.c b/alias.c
new file mode 100644
index 0000000..116cac8
--- /dev/null
+++ b/alias.c
@@ -0,0 +1,22 @@
+#include "cache.h"
+
+static const char *alias_key;
+static char *alias_val;
+static int alias_lookup_cb(const char *k, const char *v)
+{
+ if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) {
+ if (!v)
+ return config_error_nonbool(k);
+ alias_val = xstrdup(v);
+ return 0;
+ }
+ return 0;
+}
+
+char *alias_lookup(const char *alias)
+{
+ alias_key = alias;
+ alias_val = NULL;
+ git_config(alias_lookup_cb);
+ return alias_val;
+}