diff options
author | Ben Straub <bs@github.com> | 2013-02-05 22:59:58 +0400 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2013-02-05 22:59:58 +0400 |
commit | fe95ac1b6750a29d4a132d265ec1d050f49b69e8 (patch) | |
tree | d0cf8be4771619b04ab414f8320f3a9c6600bd21 /tests-clar/online/clone.c | |
parent | de81aee3907e3737ad87e88e14b702f4b3bf12a6 (diff) |
Allow progress callback to cancel fetch
This works by having the indexer watch the return
code of the callback, so will only take effect
on object boundaries.
Diffstat (limited to 'tests-clar/online/clone.c')
-rw-r--r-- | tests-clar/online/clone.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests-clar/online/clone.c b/tests-clar/online/clone.c index 6a46fa511..020c29e9f 100644 --- a/tests-clar/online/clone.c +++ b/tests-clar/online/clone.c @@ -81,11 +81,12 @@ static void checkout_progress(const char *path, size_t cur, size_t tot, void *pa (*was_called) = true; } -static void fetch_progress(const git_transfer_progress *stats, void *payload) +static int fetch_progress(const git_transfer_progress *stats, void *payload) { bool *was_called = (bool*)payload; GIT_UNUSED(stats); (*was_called) = true; + return 0; } void test_online_clone__can_checkout_a_cloned_repo(void) @@ -182,3 +183,18 @@ void test_online_clone__bitbucket_style(void) git_repository_free(g_repo); g_repo = NULL; cl_fixture_cleanup("./foo"); } + +static int cancel_at_half(const git_transfer_progress *stats, void *payload) +{ + GIT_UNUSED(payload); + + if (stats->received_objects > (stats->total_objects/2)) + return -1; + return 0; +} + +void test_online_clone__can_cancel(void) +{ + g_options.fetch_progress_cb = cancel_at_half; + cl_git_fail_with(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options), GIT_EUSER); +} |