diff options
Diffstat (limited to 'alias.c')
-rw-r--r-- | alias.c | 25 |
1 files changed, 7 insertions, 18 deletions
@@ -1,25 +1,14 @@ #include "cache.h" -static const char *alias_key; -static char *alias_val; - -static int alias_lookup_cb(const char *k, const char *v, void *cb) -{ - if (starts_with(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, NULL); - return alias_val; + char *v = NULL; + struct strbuf key = STRBUF_INIT; + strbuf_addf(&key, "alias.%s", alias); + if (git_config_key_is_valid(key.buf)) + git_config_get_string(key.buf, &v); + strbuf_release(&key); + return v; } #define SPLIT_CMDLINE_BAD_ENDING 1 |