diff options
author | Russell Belfer <rb@github.com> | 2013-11-05 03:47:35 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-11-05 03:47:35 +0400 |
commit | 3b259cbd1afdc96a3c3eb7af5895b310c1ac2a7d (patch) | |
tree | 21ceaee2cbde5248b704f09e634649393af9a9d9 /src | |
parent | d6c6016966cff46d874a8d85b38704a6ef2150e5 (diff) |
Preserve file error in iterator
When the filesystem iterator encounters an error with a file, it
returns the error but because of the cleanup code, it was in some
cases erasing the error message. This uses the giterr_detach API
to make sure that the actual error message is restored after the
cleanup code has been run.
Diffstat (limited to 'src')
-rw-r--r-- | src/iterator.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/iterator.c b/src/iterator.c index c0d7862ff..369a079bc 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -991,8 +991,20 @@ static int fs_iterator__expand_dir(fs_iterator *fi) fi->base.start, fi->base.end, &ff->entries); if (error < 0) { + git_buf msg = GIT_BUF_INIT; + git_error_t errt = giterr_detach(&msg); + + /* these callbacks may clear the error message */ fs_iterator__free_frame(ff); fs_iterator__advance_over(NULL, (git_iterator *)fi); + /* next time return value we skipped to */ + fi->base.flags &= ~GIT_ITERATOR_FIRST_ACCESS; + + if (msg.ptr) { + giterr_set_str(errt, msg.ptr); + git_buf_free(&msg); + } + return error; } |