cleanups: ensure that git-compat-util.h is included first
[gitweb.git] / combine-diff.c
index f9975d2c2ebc83e8ecfc953c8df907fbff7858f5..60cb4f81f9788efeff21d05d48f2183e94765385 100644 (file)
 #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 */