diff options
author | Russell Belfer <rb@github.com> | 2012-08-24 14:32:45 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-08-24 14:32:45 -0700 |
commit | 7fbca880aa5c011257ef734d0b5bfd5545dbaf6b (patch) | |
tree | 4013deca09f158930284631d89bcbfb379f6f879 /src/attr.c | |
parent | 07c06f7a83640e11d6be13a87f02e986ecc6e4b3 (diff) | |
download | libgit2-7fbca880aa5c011257ef734d0b5bfd5545dbaf6b.tar.gz |
Support new config locations
As of git v1.7.12, $HOME/.config/git/ is supported as a new
location for "config", "attributes", and "ignore" files.
Diffstat (limited to 'src/attr.c')
-rw-r--r-- | src/attr.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/attr.c b/src/attr.c index 8a7ff28c5..993220667 100644 --- a/src/attr.c +++ b/src/attr.c @@ -590,6 +590,18 @@ static int collect_attr_files( return error; } +static char *try_global_default(const char *relpath) +{ + git_buf dflt = GIT_BUF_INIT; + char *rval = NULL; + + if (!git_futils_find_global_file(&dflt, relpath)) + rval = git_buf_detach(&dflt); + + git_buf_free(&dflt); + + return rval; +} int git_attr_cache__init(git_repository *repo) { @@ -607,20 +619,14 @@ int git_attr_cache__init(git_repository *repo) ret = git_config_get_string(&cache->cfg_attr_file, cfg, GIT_ATTR_CONFIG); if (ret < 0 && ret != GIT_ENOTFOUND) return ret; + if (ret == GIT_ENOTFOUND) + cache->cfg_attr_file = try_global_default(GIT_ATTR_CONFIG_DEFAULT); ret = git_config_get_string(&cache->cfg_excl_file, cfg, GIT_IGNORE_CONFIG); if (ret < 0 && ret != GIT_ENOTFOUND) return ret; - - if (ret == GIT_ENOTFOUND) { - git_buf dflt = GIT_BUF_INIT; - - ret = git_futils_find_global_file(&dflt, GIT_IGNORE_CONFIG_DEFAULT); - if (!ret) - cache->cfg_excl_file = git_buf_detach(&dflt); - - git_buf_free(&dflt); - } + if (ret == GIT_ENOTFOUND) + cache->cfg_excl_file = try_global_default(GIT_IGNORE_CONFIG_DEFAULT); giterr_clear(); |