summaryrefslogtreecommitdiff
path: root/tests-clar/diff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-02-08 10:06:47 -0800
committerRussell Belfer <rb@github.com>2013-02-20 15:10:21 -0800
commit71a3d27ea686845811f04314d02798b4f1745046 (patch)
tree5a37b36475fac0da6f8b04894c5dddf74b29e8fe /tests-clar/diff
parent9bc8be3d7e5134de1d912c7ef08d6207079bd8c1 (diff)
downloadlibgit2-71a3d27ea686845811f04314d02798b4f1745046.tar.gz
Replace diff delta binary with flags
Previously the git_diff_delta recorded if the delta was binary. This replaces that (with no net change in structure size) with a full set of flags. The flag values that were already in use for individual git_diff_file objects are reused for the delta flags, too (along with renaming those flags to make it clear that they are used more generally). This (a) makes things somewhat more consistent (because I was using a -1 value in the "boolean" binary field to indicate unset, whereas now I can just use the flags that are easier to understand), and (b) will make it easier for me to add some additional flags to the delta object in the future, such as marking the results of a copy/rename detection or other deltas that might want a special indicator. While making this change, I officially moved some of the flags that were internal only into the private diff header. This also allowed me to remove a gross hack in rename/copy detect code where I was overwriting the status field with an internal value.
Diffstat (limited to 'tests-clar/diff')
-rw-r--r--tests-clar/diff/diff_helpers.c5
-rw-r--r--tests-clar/diff/diffiter.c8
2 files changed, 7 insertions, 6 deletions
diff --git a/tests-clar/diff/diff_helpers.c b/tests-clar/diff/diff_helpers.c
index 1436ada03..a1f75ce39 100644
--- a/tests-clar/diff/diff_helpers.c
+++ b/tests-clar/diff/diff_helpers.c
@@ -32,7 +32,7 @@ int diff_file_cb(
e->files++;
- if (delta->binary)
+ if ((delta->flags & GIT_DIFF_FLAG_BINARY) != 0)
e->files_binary++;
cl_assert(delta->status <= GIT_DELTA_TYPECHANGE);
@@ -126,7 +126,8 @@ int diff_foreach_via_iterator(
/* if there are no changes, then the patch will be NULL */
if (!patch) {
- cl_assert(delta->status == GIT_DELTA_UNMODIFIED || delta->binary == 1);
+ cl_assert(delta->status == GIT_DELTA_UNMODIFIED ||
+ (delta->flags & GIT_DIFF_FLAG_BINARY) != 0);
continue;
}
diff --git a/tests-clar/diff/diffiter.c b/tests-clar/diff/diffiter.c
index 8d550ec0f..932d720f2 100644
--- a/tests-clar/diff/diffiter.c
+++ b/tests-clar/diff/diffiter.c
@@ -152,8 +152,8 @@ void test_diff_diffiter__max_size_threshold(void)
file_count++;
hunk_count += (int)git_diff_patch_num_hunks(patch);
- assert(delta->binary == 0 || delta->binary == 1);
- binary_count += delta->binary;
+ assert((delta->flags & (GIT_DIFF_FLAG_BINARY|GIT_DIFF_FLAG_NOT_BINARY)) != 0);
+ binary_count += ((delta->flags & GIT_DIFF_FLAG_BINARY) != 0);
git_diff_patch_free(patch);
}
@@ -185,8 +185,8 @@ void test_diff_diffiter__max_size_threshold(void)
file_count++;
hunk_count += (int)git_diff_patch_num_hunks(patch);
- assert(delta->binary == 0 || delta->binary == 1);
- binary_count += delta->binary;
+ assert((delta->flags & (GIT_DIFF_FLAG_BINARY|GIT_DIFF_FLAG_NOT_BINARY)) != 0);
+ binary_count += ((delta->flags & GIT_DIFF_FLAG_BINARY) != 0);
git_diff_patch_free(patch);
}