diff options
| author | Russell Belfer <rb@github.com> | 2013-12-04 21:22:57 -0800 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-12-11 10:57:49 -0800 |
| commit | dab89f9b6821b67dd07c8bd4dbb53e25a3e687c7 (patch) | |
| tree | c7f4f4738dfb249b7534635226128d2e20dac6a5 /src/ignore.c | |
| parent | 96869a4edb2872934e0e167a726ab240f4270fea (diff) | |
| download | libgit2-dab89f9b6821b67dd07c8bd4dbb53e25a3e687c7.tar.gz | |
Further EUSER and error propagation fixes
This continues auditing all the places where GIT_EUSER is being
returned and making sure to clear any existing error using the
new giterr_user_cancel helper. As a result, places that relied
on intercepting GIT_EUSER but having the old error preserved also
needed to be cleaned up to correctly stash and then retrieve the
actual error.
Additionally, as I encountered places where error codes were not
being propagated correctly, I tried to fix them up. A number of
those fixes are included in the this commit as well.
Diffstat (limited to 'src/ignore.c')
| -rw-r--r-- | src/ignore.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/ignore.c b/src/ignore.c index 27d7c7ec4..aa53d409d 100644 --- a/src/ignore.c +++ b/src/ignore.c @@ -74,10 +74,20 @@ static int parse_ignore_file( #define push_ignore_file(R,IGN,S,B,F) \ git_attr_cache__push_file((R),(B),(F),GIT_ATTR_FILE_FROM_FILE,parse_ignore_file,(IGN),(S)) +struct ignores_walk_up_data { + git_ignores *ign; + git_error_state error; +}; + static int push_one_ignore(void *ref, git_buf *path) { - git_ignores *ign = (git_ignores *)ref; - return push_ignore_file(ign->repo, ign, &ign->ign_path, path->ptr, GIT_IGNORE_FILE); + struct ignores_walk_up_data *data = ref; + + return giterr_capture( + &data->error, + push_ignore_file( + data->ign->repo, data->ign, &data->ign->ign_path, + path->ptr, GIT_IGNORE_FILE) ); } static int get_internal_ignores(git_attr_file **ign, git_repository *repo) @@ -132,8 +142,13 @@ int git_ignore__for_path( /* load .gitignore up the path */ if (workdir != NULL) { + struct ignores_walk_up_data data = { ignores }; + error = git_path_walk_up( - &ignores->dir, workdir, push_one_ignore, ignores); + &ignores->dir, workdir, push_one_ignore, &data); + + if (error == GIT_EUSER) + error = giterr_restore(&data.error); if (error < 0) goto cleanup; } |
