summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 41eb33b)
raw | patch | inline | side by side (parent: 41eb33b)
author | Jeff King <peff@peff.net> | |
Sun, 24 Feb 2008 22:17:14 +0000 (17:17 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 25 Feb 2008 02:31:49 +0000 (18:31 -0800) |
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>
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>
Makefile | patch | blob | history | |
alias.c | [new file with mode: 0644] | patch | blob |
cache.h | patch | blob | history | |
git.c | patch | blob | history |
diff --git a/Makefile b/Makefile
index d33a556ffed5c2cddb9577ea014d3c017082abb8..b460bb21645c3d0c328a00156a2e020167df6b80 100644 (file)
--- a/Makefile
+++ b/Makefile
alloc.o merge-file.o path-list.o help.o unpack-trees.o $(DIFF_OBJS) \
color.o wt-status.o archive-zip.o archive-tar.o shallow.o utf8.o \
convert.o attr.o decorate.o progress.o mailmap.o symlinks.o remote.o \
- transport.o bundle.o walker.o parse-options.o ws.o archive.o
+ transport.o bundle.o walker.o parse-options.o ws.o archive.o \
+ alias.o
BUILTIN_OBJS = \
builtin-add.o \
diff --git a/alias.c b/alias.c
--- /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;
+}
index fa5a9e523eda0f075a4e36fcf3b4c0760e54f583..1e9c9372999bb237b984303f48111e68fcfb6554 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -765,4 +765,6 @@ int pathspec_match(const char **spec, char *matched, const char *filename, int s
int report_path_error(const char *ps_matched, const char **pathspec, int prefix_offset);
void overlay_tree_on_cache(const char *tree_name, const char *prefix);
+char *alias_lookup(const char *alias);
+
#endif /* CACHE_H */
index 0cb86884d738a8314f164c82e4cc619a9998f3db..8f08b12295e1641577ffd61ee71c7b7247645f81 100644 (file)
--- a/git.c
+++ b/git.c
return handled;
}
-static const char *alias_command;
-static char *alias_string;
-
-static int git_alias_config(const char *var, const char *value)
-{
- if (!prefixcmp(var, "alias.") && !strcmp(var + 6, alias_command)) {
- if (!value)
- return config_error_nonbool(var);
- alias_string = xstrdup(value);
- }
- return 0;
-}
-
static int split_cmdline(char *cmdline, const char ***argv)
{
int src, dst, count = 0, size = 16;
const char *subdir;
int count, option_count;
const char** new_argv;
+ const char *alias_command;
+ char *alias_string;
subdir = setup_git_directory_gently(&nongit);
alias_command = (*argv)[0];
- git_config(git_alias_config);
+ alias_string = alias_lookup(alias_command);
if (alias_string) {
if (alias_string[0] == '!') {
if (*argcp > 1) {