summaryrefslogtreecommitdiff
path: root/src/attr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/attr.c')
-rw-r--r--src/attr.c21
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);