diff options
| author | Vicent Marti <vicent@github.com> | 2013-12-13 06:20:19 -0800 |
|---|---|---|
| committer | Vicent Marti <vicent@github.com> | 2013-12-13 06:20:19 -0800 |
| commit | 79194bcdc956406979cd27ac99198826860d3f20 (patch) | |
| tree | 407594b97b6e39ef3ac0723dc33aa3162ce933cc /src/attr.c | |
| parent | 25a1fab0a96fd87e4ebc4ec195ac59a4213e92ad (diff) | |
| parent | 7a16d54b5457aa9f60c25a204277ae0ce609ad2e (diff) | |
| download | libgit2-79194bcdc956406979cd27ac99198826860d3f20.tar.gz | |
Merge pull request #1986 from libgit2/rb/error-handling-cleanups
Clean up some error handling and change callback error behavior
Diffstat (limited to 'src/attr.c')
| -rw-r--r-- | src/attr.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/attr.c b/src/attr.c index 98a328a55..e6e274e42 100644 --- a/src/attr.c +++ b/src/attr.c @@ -193,8 +193,7 @@ int git_attr_foreach( error = callback(assign->name, assign->value, payload); if (error) { - giterr_clear(); - error = GIT_EUSER; + giterr_set_after_callback(error); goto cleanup; } } @@ -536,7 +535,7 @@ static int collect_attr_files( int error; git_buf dir = GIT_BUF_INIT; const char *workdir = git_repository_workdir(repo); - attr_walk_up_info info; + attr_walk_up_info info = { NULL }; if (git_attr_cache__init(repo) < 0 || git_vector_init(files, 4, NULL) < 0) @@ -603,11 +602,15 @@ static int attr_cache__lookup_path( { git_buf buf = GIT_BUF_INIT; int error; - const char *cfgval = NULL; + const git_config_entry *entry = NULL; *out = NULL; - if (!(error = git_config_get_string(&cfgval, cfg, key))) { + if ((error = git_config__lookup_entry(&entry, cfg, key, false)) < 0) + return error; + + if (entry) { + const char *cfgval = entry->value; /* expand leading ~/ as needed */ if (cfgval && cfgval[0] == '~' && cfgval[1] == '/' && @@ -616,13 +619,9 @@ static int attr_cache__lookup_path( else if (cfgval) *out = git__strdup(cfgval); - } else if (error == GIT_ENOTFOUND) { - giterr_clear(); - error = 0; - - if (!git_futils_find_xdg_file(&buf, fallback)) - *out = git_buf_detach(&buf); } + else if (!git_futils_find_xdg_file(&buf, fallback)) + *out = git_buf_detach(&buf); git_buf_free(&buf); |
