diff options
author | Russell Belfer <rb@github.com> | 2012-04-11 22:52:59 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-04-11 23:11:35 +0400 |
commit | 7784bcbbee972d1f00ea88655a5592fb44ca767d (patch) | |
tree | 75926bc03a5f7f072878af8eb3e0e37b7fa66d4f /src/attr.c | |
parent | 1de77cd31432a1bdff060181c6d9ec25a412a0c2 (diff) |
Refactor git_repository_open with new options
Add a new command `git_repository_open_ext` with extended options
that control how searching for a repository will be done. The
existing `git_repository_open` and `git_repository_discover` are
reimplemented on top of it. We may want to change the default
behavior of `git_repository_open` but this commit does not do that.
Improve support for "gitdir" files where the work dir is separate
from the repo and support for the "separate-git-dir" config. Also,
add support for opening repos created with `git-new-workdir` script
(although I have only confirmed that they can be opened, not that
all functions work correctly).
There are also a few minor changes that came up:
- Fix `git_path_prettify` to allow in-place prettifying.
- Fix `git_path_root` to support backslashes on Win32. This fix
should help many repo open/discover scenarios - it is the one
function called when opening before prettifying the path.
- Tweak `git_config_get_string` to set the "out" pointer to NULL
if the config value is not found. Allows some other cleanup.
- Fix a couple places that should have been calling
`git_repository_config__weakptr` and were not.
- Fix `cl_git_sandbox_init` clar helper to support bare repos.
Diffstat (limited to 'src/attr.c')
-rw-r--r-- | src/attr.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/attr.c b/src/attr.c index 5cf96acf7..c02289363 100644 --- a/src/attr.c +++ b/src/attr.c @@ -347,6 +347,7 @@ static int collect_attr_files( int git_attr_cache__init(git_repository *repo) { + int ret; git_attr_cache *cache = git_repository_attr_cache(repo); git_config *cfg; @@ -354,17 +355,18 @@ int git_attr_cache__init(git_repository *repo) return 0; /* cache config settings for attributes and ignores */ - if (git_repository_config(&cfg, repo) < 0) + if (git_repository_config__weakptr(&cfg, repo) < 0) return -1; - if (git_config_get_string(cfg, GIT_ATTR_CONFIG, &cache->cfg_attr_file)) { - giterr_clear(); - cache->cfg_attr_file = NULL; - } - if (git_config_get_string(cfg, GIT_IGNORE_CONFIG, &cache->cfg_excl_file)) { - giterr_clear(); - cache->cfg_excl_file = NULL; - } - git_config_free(cfg); + + ret = git_config_get_string(cfg, GIT_ATTR_CONFIG, &cache->cfg_attr_file); + if (ret < 0 && ret != GIT_ENOTFOUND) + return ret; + + ret = git_config_get_string(cfg, GIT_IGNORE_CONFIG, &cache->cfg_excl_file); + if (ret < 0 && ret != GIT_ENOTFOUND) + return ret; + + giterr_clear(); /* allocate hashtable for attribute and ignore file contents */ if (cache->files == NULL) { |