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-05-18 03:57:49 +0400
committerRussell Belfer <rb@github.com>2013-05-18 03:57:49 +0400
commit0293450e217c1cb6966655bb00cc11fdf626083d (patch)
tree6b9d89ccc71b9c22d60b0280cfe93bf283f8a9a9 /src/diff.c
parentaadfa85b0a8f9a8fec4dedd149017a769d54d930 (diff)
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.
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/diff.c b/src/diff.c
index d93506984..d2389f103 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -231,10 +231,23 @@ static char *diff_strdup_prefix(git_pool *pool, const char *prefix)
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)
{
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);
}