diff options
author | Russell Belfer <rb@github.com> | 2012-10-23 16:40:51 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-10-23 16:40:51 -0700 |
commit | b4f5bb074721823cc016b66a9984abe2c271cb1f (patch) | |
tree | 946a7522e701442786cdec870a9035f4bde097a4 /tests-clar/diff/diff_helpers.c | |
parent | 5b67d145d8f465ed0c7ed9c07d331aae29c2713b (diff) | |
download | libgit2-b4f5bb074721823cc016b66a9984abe2c271cb1f.tar.gz |
Initial implementation of diff rename detection
This implements the basis for diff rename and copy detection,
although it is based on simple SHA comparison right now instead
of using a matching algortihm. Just as `git_diff_merge` can be
used as a post-pass on diffs to emulate certain command line
behaviors, there is a new API `git_diff_detect` which will
update a diff list in-place, adjusting some deltas to RENAMED
or COPIED state (and also, eventually, splitting MODIFIED deltas
where the change is too large into DELETED/ADDED pairs).
This also adds a new test repo that will hold rename/copy/split
scenarios. Right now, it just has exact-match rename and copy,
but the tests are written to use tree diffs, so we should be able
to add new test scenarios easily without breaking tests.
Diffstat (limited to 'tests-clar/diff/diff_helpers.c')
-rw-r--r-- | tests-clar/diff/diff_helpers.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c index de0e7e074..992c87d4c 100644 --- a/tests-clar/diff/diff_helpers.c +++ b/tests-clar/diff/diff_helpers.c @@ -32,20 +32,13 @@ int diff_file_fn( e->files++; - if (delta->binary) { - e->at_least_one_of_them_is_binary = true; + if (delta->binary) e->files_binary++; - } - switch (delta->status) { - case GIT_DELTA_ADDED: e->file_adds++; break; - case GIT_DELTA_DELETED: e->file_dels++; break; - case GIT_DELTA_MODIFIED: e->file_mods++; break; - case GIT_DELTA_IGNORED: e->file_ignored++; break; - case GIT_DELTA_UNTRACKED: e->file_untracked++; break; - case GIT_DELTA_UNMODIFIED: e->file_unmodified++; break; - default: break; - } + cl_assert(delta->status <= GIT_DELTA_TYPECHANGE); + + e->file_status[delta->status] += 1; + return 0; } |