summaryrefslogtreecommitdiff
path: root/combine-diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-08-26 11:16:26 -0700
committerJunio C Hamano <gitster@pobox.com>2014-08-26 11:16:26 -0700
commit4109c28e055dba27d73cefb956bea5e611f66ec0 (patch)
tree8b323ced930a0eb5bb7912059506278f88ec36a9 /combine-diff.c
parenta3d54f9a1fa481727a849b8753fc9d1abafe6583 (diff)
parente09867f0605702c2d4e65b99e178cdaa215a7370 (diff)
downloadgit-4109c28e055dba27d73cefb956bea5e611f66ec0.tar.gz
Merge branch 'jk/diff-tree-t-fix'
Fix (rarely used) "git diff-tree -t" regression in 2.0. * jk/diff-tree-t-fix: intersect_paths: respect mode in git's tree-sort
Diffstat (limited to 'combine-diff.c')
-rw-r--r--combine-diff.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/combine-diff.c b/combine-diff.c
index f9975d2c2e..60cb4f81f9 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -12,6 +12,16 @@
#include "sha1-array.h"
#include "revision.h"
+static int compare_paths(const struct combine_diff_path *one,
+ const struct diff_filespec *two)
+{
+ if (!S_ISDIR(one->mode) && !S_ISDIR(two->mode))
+ return strcmp(one->path, two->path);
+
+ return base_name_compare(one->path, strlen(one->path), one->mode,
+ two->path, strlen(two->path), two->mode);
+}
+
static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr, int n, int num_parent)
{
struct diff_queue_struct *q = &diff_queued_diff;
@@ -52,7 +62,7 @@ static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr,
i = 0;
while ((p = *tail) != NULL) {
cmp = ((i >= q->nr)
- ? -1 : strcmp(p->path, q->queue[i]->two->path));
+ ? -1 : compare_paths(p, q->queue[i]->two));
if (cmp < 0) {
/* p->path not in q->queue[]; drop it */