summaryrefslogtreecommitdiff
path: root/tests-clar/diff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-09-10 09:59:14 -0700
committerRussell Belfer <rb@github.com>2012-09-10 09:59:14 -0700
commitb36effa22e015871948daeea250b4996c663e11a (patch)
tree17841fe3ca402f27c255a60f6cf2f6698dc96d1c /tests-clar/diff
parent3a3deea80bb6555706f58006bdee8e878b0fd651 (diff)
downloadlibgit2-b36effa22e015871948daeea250b4996c663e11a.tar.gz
Replace git_diff_iterator_num_files with progress
The `git_diff_iterator_num_files` API was problematic, since we don't actually know the exact number of files to be iterated over until we load those files into memory. This replaces it with a new `git_diff_iterator_progress` API that goes from 0 to 1, and moves and renamed the old API for the internal places that can tolerate a max value instead of an exact value.
Diffstat (limited to 'tests-clar/diff')
-rw-r--r--tests-clar/diff/diff_helpers.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c
index 59e01802c..ef59b686f 100644
--- a/tests-clar/diff/diff_helpers.c
+++ b/tests-clar/diff/diff_helpers.c
@@ -111,23 +111,21 @@ int diff_foreach_via_iterator(
git_diff_hunk_fn hunk_cb,
git_diff_data_fn line_cb)
{
- int error, curr, total;
+ int error;
git_diff_iterator *iter;
git_diff_delta *delta;
if ((error = git_diff_iterator_new(&iter, diff)) < 0)
return error;
- curr = 0;
- total = git_diff_iterator_num_files(iter);
-
while (!(error = git_diff_iterator_next_file(&delta, iter))) {
git_diff_range *range;
const char *hdr;
size_t hdr_len;
+ float progress = git_diff_iterator_progress(iter);
/* call file_cb for this file */
- if (file_cb != NULL && file_cb(data, delta, (float)curr / total) != 0)
+ if (file_cb != NULL && file_cb(data, delta, progress) != 0)
goto abort;
if (!hunk_cb && !line_cb)