Commit 0293450e by Russell Belfer

Fix delta compare to use correct pathname

The delta cmp function needs to choose the correct path for
ordering when a delta is ADDED, RENAMED, or COPIED.
parent aadfa85b
...@@ -231,10 +231,23 @@ static char *diff_strdup_prefix(git_pool *pool, const char *prefix) ...@@ -231,10 +231,23 @@ static char *diff_strdup_prefix(git_pool *pool, const char *prefix)
return git_pool_strndup(pool, prefix, len + 1); return git_pool_strndup(pool, prefix, len + 1);
} }
GIT_INLINE(const char *) diff_delta__path(const git_diff_delta *delta)
{
const char *str = delta->old_file.path;
if (!str ||
delta->status == GIT_DELTA_ADDED ||
delta->status == GIT_DELTA_RENAMED ||
delta->status == GIT_DELTA_COPIED)
str = delta->new_file.path;
return str;
}
int git_diff_delta__cmp(const void *a, const void *b) int git_diff_delta__cmp(const void *a, const void *b)
{ {
const git_diff_delta *da = a, *db = b; const git_diff_delta *da = a, *db = b;
int val = strcmp(da->old_file.path, db->old_file.path); int val = strcmp(diff_delta__path(da), diff_delta__path(db));
return val ? val : ((int)da->status - (int)db->status); return val ? val : ((int)da->status - (int)db->status);
} }
......
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