Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-02-08 22:06:47 +0400
committerRussell Belfer <rb@github.com>2013-02-21 03:10:21 +0400
commit71a3d27ea686845811f04314d02798b4f1745046 (patch)
tree5a37b36475fac0da6f8b04894c5dddf74b29e8fe /src/diff_tform.c
parent9bc8be3d7e5134de1d912c7ef08d6207079bd8c1 (diff)
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 'src/diff_tform.c')
-rw-r--r--src/diff_tform.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/diff_tform.c b/src/diff_tform.c
index 61cf5b392..e051732c5 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -315,10 +315,10 @@ static int apply_splits_and_deletes(git_diff_list *diff, size_t expected_size)
/* build new delta list without TO_DELETE and splitting TO_SPLIT */
git_vector_foreach(&diff->deltas, i, delta) {
- if (delta->status == GIT_DELTA__TO_DELETE)
+ if ((delta->flags & GIT_DIFF_FLAG__TO_DELETE) != 0)
continue;
- if (delta->status == GIT_DELTA__TO_SPLIT) {
+ if ((delta->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0) {
git_diff_delta *deleted = diff_delta__dup(delta, &diff->pool);
if (!deleted)
goto on_error;
@@ -326,7 +326,7 @@ static int apply_splits_and_deletes(git_diff_list *diff, size_t expected_size)
deleted->status = GIT_DELTA_DELETED;
memset(&deleted->new_file, 0, sizeof(deleted->new_file));
deleted->new_file.path = deleted->old_file.path;
- deleted->new_file.flags |= GIT_DIFF_FILE_VALID_OID;
+ deleted->new_file.flags |= GIT_DIFF_FLAG_VALID_OID;
if (git_vector_insert(&onto, deleted) < 0)
goto on_error;
@@ -334,7 +334,7 @@ static int apply_splits_and_deletes(git_diff_list *diff, size_t expected_size)
delta->status = GIT_DELTA_ADDED;
memset(&delta->old_file, 0, sizeof(delta->old_file));
delta->old_file.path = delta->new_file.path;
- delta->old_file.flags |= GIT_DIFF_FILE_VALID_OID;
+ delta->old_file.flags |= GIT_DIFF_FLAG_VALID_OID;
}
if (git_vector_insert(&onto, delta) < 0)
@@ -343,7 +343,7 @@ static int apply_splits_and_deletes(git_diff_list *diff, size_t expected_size)
/* cannot return an error past this point */
git_vector_foreach(&diff->deltas, i, delta)
- if (delta->status == GIT_DELTA__TO_DELETE)
+ if ((delta->flags & GIT_DIFF_FLAG__TO_DELETE) != 0)
git__free(delta);
/* swap new delta list into place */
@@ -411,7 +411,7 @@ int git_diff_find_similar(
/* calc_similarity(NULL, &from->old_file, from->new_file); */
if (similarity < opts.break_rewrite_threshold) {
- from->status = GIT_DELTA__TO_SPLIT;
+ from->flags |= GIT_DIFF_FLAG__TO_SPLIT;
num_changes++;
}
}
@@ -502,7 +502,7 @@ int git_diff_find_similar(
to->status = GIT_DELTA_RENAMED;
memcpy(&to->old_file, &from->old_file, sizeof(to->old_file));
- from->status = GIT_DELTA__TO_DELETE;
+ from->flags |= GIT_DIFF_FLAG__TO_DELETE;
num_changes++;
continue;
@@ -522,7 +522,7 @@ int git_diff_find_similar(
from->status = GIT_DELTA_ADDED;
memset(&from->old_file, 0, sizeof(from->old_file));
from->old_file.path = to->old_file.path;
- from->old_file.flags |= GIT_DIFF_FILE_VALID_OID;
+ from->old_file.flags |= GIT_DIFF_FLAG_VALID_OID;
continue;
}