summaryrefslogtreecommitdiff
path: root/src/diff.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-05-19 18:26:04 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-05-28 09:47:47 -0400
commit10549a2df166cd3b951c65ab89c33f7ef21c6b7a (patch)
tree0bf109c7f9cc662b9912970e757c981bfccc68cc /src/diff.c
parent666ae188215557fb440b74f6af6e5cfbec27d459 (diff)
downloadlibgit2-10549a2df166cd3b951c65ab89c33f7ef21c6b7a.tar.gz
Introduce `GIT_DIFF_FLAG_EXISTS`
Mark the `old_file` and `new_file` sides of a delta with a new bit, `GIT_DIFF_FLAG_EXISTS`, that introduces that a particular side of the delta exists in the diff. This is useful for indicating whether a working directory item exists or not, in the presence of a conflict. Diff users may have previously used DELETED to determine this information.
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/diff.c b/src/diff.c
index d4f7d260c..c9d1d8730 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -127,10 +127,12 @@ static int diff_delta__from_one(
if (has_old) {
delta->old_file.mode = entry->mode;
delta->old_file.size = entry->file_size;
+ delta->old_file.flags |= GIT_DIFF_FLAG_EXISTS;
git_oid_cpy(&delta->old_file.id, &entry->id);
} else /* ADDED, IGNORED, UNTRACKED */ {
delta->new_file.mode = entry->mode;
delta->new_file.size = entry->file_size;
+ delta->new_file.flags |= GIT_DIFF_FLAG_EXISTS;
git_oid_cpy(&delta->new_file.id, &entry->id);
}
@@ -184,13 +186,16 @@ static int diff_delta__from_two(
delta->old_file.size = old_entry->file_size;
delta->old_file.mode = old_mode;
git_oid_cpy(&delta->old_file.id, old_id);
- delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID;
+ delta->old_file.flags |= GIT_DIFF_FLAG_VALID_ID |
+ GIT_DIFF_FLAG_EXISTS;
}
if (!git_index_entry_is_conflict(new_entry)) {
git_oid_cpy(&delta->new_file.id, new_id);
delta->new_file.size = new_entry->file_size;
delta->new_file.mode = new_mode;
+ delta->old_file.flags |= GIT_DIFF_FLAG_EXISTS;
+ delta->new_file.flags |= GIT_DIFF_FLAG_EXISTS;
if (!git_oid_iszero(&new_entry->id))
delta->new_file.flags |= GIT_DIFF_FLAG_VALID_ID;