Commit 83ba5e36 by Edward Thomson

diff_tform: remove reversed copy of delta merger

Drop `git_diff__merge_like_cgit_reversed`, since it's a copy and
paste mess of slightly incompatible changes.
parent 0c34fa50
...@@ -80,10 +80,11 @@ static git_diff_delta *diff_delta__merge_like_cgit( ...@@ -80,10 +80,11 @@ static git_diff_delta *diff_delta__merge_like_cgit(
return NULL; return NULL;
/* If 'a' status is uninteresting, then we're done */ /* If 'a' status is uninteresting, then we're done */
if (a->status == GIT_DELTA_UNMODIFIED) if (a->status == GIT_DELTA_UNMODIFIED ||
a->status == GIT_DELTA_UNTRACKED ||
a->status == GIT_DELTA_UNREADABLE)
return dup; return dup;
assert(a->status != GIT_DELTA_UNMODIFIED);
assert(b->status != GIT_DELTA_UNMODIFIED); assert(b->status != GIT_DELTA_UNMODIFIED);
/* A cgit exception is that the diff of a file that is only in the /* A cgit exception is that the diff of a file that is only in the
...@@ -108,47 +109,6 @@ static git_diff_delta *diff_delta__merge_like_cgit( ...@@ -108,47 +109,6 @@ static git_diff_delta *diff_delta__merge_like_cgit(
return dup; return dup;
} }
static git_diff_delta *diff_delta__merge_like_cgit_reversed(
const git_diff_delta *a,
const git_diff_delta *b,
git_pool *pool)
{
git_diff_delta *dup;
/* reversed version of above logic */
if (a->status == GIT_DELTA_CONFLICTED)
return diff_delta__dup(a, pool);
if (b->status == GIT_DELTA_CONFLICTED)
return diff_delta__dup(b, pool);
if (a->status == GIT_DELTA_UNMODIFIED)
return diff_delta__dup(b, pool);
if ((dup = diff_delta__dup(a, pool)) == NULL)
return NULL;
if (b->status == GIT_DELTA_UNMODIFIED || b->status == GIT_DELTA_UNTRACKED || b->status == GIT_DELTA_UNREADABLE)
return dup;
if (dup->status == GIT_DELTA_DELETED) {
if (b->status == GIT_DELTA_ADDED) {
dup->status = GIT_DELTA_UNMODIFIED;
dup->nfiles = 2;
}
} else {
dup->status = b->status;
dup->nfiles = b->nfiles;
}
git_oid_cpy(&dup->old_file.id, &b->old_file.id);
dup->old_file.mode = b->old_file.mode;
dup->old_file.size = b->old_file.size;
dup->old_file.flags = b->old_file.flags;
return dup;
}
int git_diff_merge(git_diff *onto, const git_diff *from) int git_diff_merge(git_diff *onto, const git_diff *from)
{ {
int error = 0; int error = 0;
...@@ -191,9 +151,10 @@ int git_diff_merge(git_diff *onto, const git_diff *from) ...@@ -191,9 +151,10 @@ int git_diff_merge(git_diff *onto, const git_diff *from)
delta = diff_delta__dup(f, &onto_pool); delta = diff_delta__dup(f, &onto_pool);
j++; j++;
} else { } else {
delta = reversed ? const git_diff_delta *left = reversed ? f : o;
diff_delta__merge_like_cgit_reversed(o, f, &onto_pool) : const git_diff_delta *right = reversed ? o : f;
diff_delta__merge_like_cgit(o, f, &onto_pool);
delta = diff_delta__merge_like_cgit(left, right, &onto_pool);
i++; i++;
j++; j++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment