]> git.proxmox.com Git - libgit2.git/commit - tests/odb/foreach.c
Remove converting user error to GIT_EUSER
authorRussell Belfer <rb@github.com>
Fri, 6 Dec 2013 23:07:57 +0000 (15:07 -0800)
committerRussell Belfer <rb@github.com>
Wed, 11 Dec 2013 18:57:49 +0000 (10:57 -0800)
commit25e0b1576d5f9e5248603f81d3198a65bfccf0ed
treedac0da29acfbd6478bed93bcab3557e2877dabaa
parentfcd324c625d8be3f368c924d787e945e5812d8dd
Remove converting user error to GIT_EUSER

This changes the behavior of callbacks so that the callback error
code is not converted into GIT_EUSER and instead we propagate the
return value through to the caller.  Instead of using the
giterr_capture and giterr_restore functions, we now rely on all
functions to pass back the return value from a callback.

To avoid having a return value with no error message, the user
can call the public giterr_set_str or some such function to set
an error message.  There is a new helper 'giterr_set_callback'
that functions can invoke after making a callback which ensures
that some error message was set in case the callback did not set
one.

In places where the sign of the callback return value is
meaningful (e.g. positive to skip, negative to abort), only the
negative values are returned back to the caller, obviously, since
the other values allow for continuing the loop.

The hardest parts of this were in the checkout code where positive
return values were overloaded as meaningful values for checkout.
I fixed this by adding an output parameter to many of the internal
checkout functions and removing the overload.  This added some
code, but it is probably a better implementation.

There is some funkiness in the network code where user provided
callbacks could be returning a positive or a negative value and
we want to rely on that to cancel the loop.  There are still a
couple places where an user error might get turned into GIT_EUSER
there, I think, though none exercised by the tests.
57 files changed:
include/git2/config.h
include/git2/errors.h
src/attr.c
src/checkout.c
src/clone.c
src/common.h
src/config.c
src/diff.c
src/diff_patch.c
src/diff_print.c
src/diff_xdiff.c
src/fetch.c
src/fetchhead.c
src/fileops.c
src/ignore.c
src/index.c
src/indexer.c
src/merge.c
src/notes.c
src/odb_loose.c
src/odb_pack.c
src/pack-objects.c
src/pack.c
src/path.c
src/path.h
src/push.c
src/refdb_fs.c
src/refs.c
src/remote.c
src/repository.c
src/revwalk.c
src/stash.c
src/status.c
src/submodule.c
src/tag.c
src/transports/http.c
src/transports/local.c
src/transports/smart.c
src/transports/smart_protocol.c
src/transports/winhttp.c
src/tree.c
src/vector.c
src/vector.h
tests/attr/repo.c
tests/config/read.c
tests/config/rename.c
tests/core/path.c
tests/diff/index.c
tests/diff/notify.c
tests/diff/rename.c
tests/notes/notes.c
tests/object/tree/walk.c
tests/odb/foreach.c
tests/online/clone.c
tests/online/fetch.c
tests/refs/foreachglob.c
tests/status/worktree.c