summaryrefslogtreecommitdiff
path: root/src/diff.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-05-19 11:23:59 -0400
committerEdward Thomson <ethomson@microsoft.com>2015-05-28 09:47:31 -0400
commit9f545b9d71c7bd316be80e5fe8b47135e9deb97e (patch)
treed2cf3279b4fd716fcea963a2a0118dd522a52270 /src/diff.c
parent2f1080ea04ad1235efcd4b213dbe3a1b847644f7 (diff)
downloadlibgit2-9f545b9d71c7bd316be80e5fe8b47135e9deb97e.tar.gz
introduce `git_index_entry_is_conflict`
It's not always obvious the mapping between stage level and conflict-ness. More importantly, this can lead otherwise sane people to write constructs like `if (!git_index_entry_stage(entry))`, which (while technically correct) is unreadable. Provide a nice method to help avoid such messy thinking.
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/diff.c b/src/diff.c
index abe0de0d4..46f339692 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -180,14 +180,14 @@ static int diff_delta__from_two(
GITERR_CHECK_ALLOC(delta);
delta->nfiles = 2;
- if (!git_index_entry_stage(old_entry)) {
+ if (!git_index_entry_is_conflict(old_entry)) {
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;
}
- if (!git_index_entry_stage(new_entry)) {
+ 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;
@@ -765,7 +765,8 @@ static int maybe_modified(
nmode = (nmode & ~MODE_BITS_MASK) | (omode & MODE_BITS_MASK);
/* if one side is a conflict, mark the whole delta as conflicted */
- if (git_index_entry_stage(oitem) > 0 || git_index_entry_stage(nitem) > 0)
+ if (git_index_entry_is_conflict(oitem) ||
+ git_index_entry_is_conflict(nitem))
status = GIT_DELTA_CONFLICTED;
/* support "assume unchanged" (poorly, b/c we still stat everything) */
@@ -923,8 +924,8 @@ static int iterator_advance(
*/
while ((error = git_iterator_advance(entry, iterator)) == 0) {
if (!(iterator->flags & GIT_ITERATOR_INCLUDE_CONFLICTS) ||
- git_index_entry_stage(prev_entry) == 0 ||
- git_index_entry_stage(*entry) == 0)
+ !git_index_entry_is_conflict(prev_entry) ||
+ !git_index_entry_is_conflict(*entry))
break;
cmp = (iterator->flags & GIT_ITERATOR_IGNORE_CASE) ?
@@ -985,7 +986,7 @@ static int handle_unmatched_new_item(
contains_oitem = entry_is_prefixed(diff, info->oitem, nitem);
/* update delta_type if this item is conflicted */
- if (git_index_entry_stage(nitem))
+ if (git_index_entry_is_conflict(nitem))
delta_type = GIT_DELTA_CONFLICTED;
/* update delta_type if this item is ignored */
@@ -1133,7 +1134,7 @@ static int handle_unmatched_old_item(
int error;
/* update delta_type if this item is conflicted */
- if (git_index_entry_stage(info->oitem))
+ if (git_index_entry_is_conflict(info->oitem))
delta_type = GIT_DELTA_CONFLICTED;
if ((error = diff_delta__from_one(diff, delta_type, info->oitem, NULL)) < 0)