diff options
author | Russell Belfer <rb@github.com> | 2012-09-10 09:59:14 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-09-10 09:59:14 -0700 |
commit | b36effa22e015871948daeea250b4996c663e11a (patch) | |
tree | 17841fe3ca402f27c255a60f6cf2f6698dc96d1c /src/diff.h | |
parent | 3a3deea80bb6555706f58006bdee8e878b0fd651 (diff) | |
download | libgit2-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 'src/diff.h')
-rw-r--r-- | src/diff.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/diff.h b/src/diff.h index def746323..ea38a678f 100644 --- a/src/diff.h +++ b/src/diff.h @@ -42,5 +42,27 @@ struct git_diff_list { extern void git_diff__cleanup_modes( uint32_t diffcaps, uint32_t *omode, uint32_t *nmode); +/** + * Return the maximum possible number of files in the diff. + * + * NOTE: This number has to be treated as an upper bound on the number of + * files that have changed if the diff is with the working directory. + * + * Why?! For efficiency, we defer loading the file contents as long as + * possible, so if a file has been "touched" in the working directory and + * then reverted to the original content, it may get stored in the diff list + * as MODIFIED along with a flag that the status should be reconfirmed when + * it is actually loaded into memory. When that load happens, it could get + * flipped to UNMODIFIED. If unmodified files are being skipped, then the + * iterator will skip that file and this number may be too high. + * + * This behavior is true of `git_diff_foreach` as well, but the only + * implication there is that the `progress` value would not advance evenly. + * + * @param iterator The iterator object + * @return The maximum number of files to be iterated over + */ +int git_diff_iterator__max_files(git_diff_iterator *iterator); + #endif |