diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2022-02-21 09:06:56 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 09:06:56 -0500 |
commit | 1551b1f02b534390f26c57f6b06b9d8582982db8 (patch) | |
tree | bcaab123e2fff5c85ed17ce57f0d657577ce21ff | |
parent | 83f2a20eb7727fcf418a17c75cb088ce2cc432ec (diff) | |
parent | e35b5e44aa65d0289347ea199b7954a2a556ad9a (diff) | |
download | libgit2-1551b1f02b534390f26c57f6b06b9d8582982db8.tar.gz |
Merge pull request #6226 from libgit2/cmn/update-tips-error
remote: do store the update_tips callback error value
-rw-r--r-- | src/remote.c | 2 | ||||
-rw-r--r-- | tests/network/fetchlocal.c | 41 |
2 files changed, 42 insertions, 1 deletions
diff --git a/src/remote.c b/src/remote.c index 038afc6f5..f6421b9eb 100644 --- a/src/remote.c +++ b/src/remote.c @@ -1852,7 +1852,7 @@ static int update_one_tip( } if (callbacks && callbacks->update_tips != NULL && - callbacks->update_tips(refname.ptr, &old, &head->oid, callbacks->payload) < 0) + (error = callbacks->update_tips(refname.ptr, &old, &head->oid, callbacks->payload)) < 0) git_error_set_after_callback_function(error, "git_remote_fetch"); done: diff --git a/tests/network/fetchlocal.c b/tests/network/fetchlocal.c index c54f45472..dc37c38ab 100644 --- a/tests/network/fetchlocal.c +++ b/tests/network/fetchlocal.c @@ -509,3 +509,44 @@ void test_network_fetchlocal__prune_load_fetch_prune_config(void) git_remote_free(origin); git_repository_free(repo); } + +static int update_tips_error(const char *ref, const git_oid *old, const git_oid *new, void *data) +{ + int *callcount = (int *) data; + + GIT_UNUSED(ref); + GIT_UNUSED(old); + GIT_UNUSED(new); + + (*callcount)++; + + return -1; +} + +void test_network_fetchlocal__update_tips_error_is_propagated(void) +{ + git_repository *repo; + git_reference_iterator *iterator; + git_reference *ref; + git_remote *remote; + git_fetch_options options = GIT_FETCH_OPTIONS_INIT; + int callcount = 0; + + cl_git_pass(git_repository_init(&repo, "foo.git", true)); + cl_set_cleanup(cleanup_local_repo, "foo.git"); + + cl_git_pass(git_remote_create_with_fetchspec(&remote, repo, "origin", cl_git_fixture_url("testrepo.git"), "+refs/heads/*:refs/remotes/update-tips/*")); + + options.callbacks.update_tips = update_tips_error; + options.callbacks.payload = &callcount; + + cl_git_fail(git_remote_fetch(remote, NULL, &options, NULL)); + cl_assert_equal_i(1, callcount); + + cl_git_pass(git_reference_iterator_glob_new(&iterator, repo, "refs/remotes/update-tips/**/")); + cl_assert_equal_i(GIT_ITEROVER, git_reference_next(&ref, iterator)); + + git_reference_iterator_free(iterator); + git_remote_free(remote); + git_repository_free(repo); +} |