From b36effa22e015871948daeea250b4996c663e11a Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 10 Sep 2012 09:59:14 -0700 Subject: 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. --- tests-clar/diff/diff_helpers.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tests-clar/diff/diff_helpers.c') 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) -- cgit v1.2.1