name-hash: properly fold directory names in adjust_dirname_case()
[gitweb.git] / diffcore-rename.c
index 8ce3b7d661d356955eee8c179850c2d933fd9694..15c014d864c65e2a6dd17523bacf1681a276db01 100644 (file)
@@ -60,7 +60,8 @@ static int add_rename_dst(struct diff_filespec *two)
                memmove(rename_dst + first + 1, rename_dst + first,
                        (rename_dst_nr - first - 1) * sizeof(*rename_dst));
        rename_dst[first].two = alloc_filespec(two->path);
-       fill_filespec(rename_dst[first].two, two->sha1, two->sha1_valid, two->mode);
+       fill_filespec(rename_dst[first].two, two->oid.hash, two->oid_valid,
+                     two->mode);
        rename_dst[first].pair = NULL;
        return 0;
 }
@@ -256,12 +257,13 @@ struct file_similarity {
 
 static unsigned int hash_filespec(struct diff_filespec *filespec)
 {
-       if (!filespec->sha1_valid) {
+       if (!filespec->oid_valid) {
                if (diff_populate_filespec(filespec, 0))
                        return 0;
-               hash_sha1_file(filespec->data, filespec->size, "blob", filespec->sha1);
+               hash_sha1_file(filespec->data, filespec->size, "blob",
+                              filespec->oid.hash);
        }
-       return sha1hash(filespec->sha1);
+       return sha1hash(filespec->oid.hash);
 }
 
 static int find_identical_files(struct hashmap *srcs,
@@ -283,7 +285,7 @@ static int find_identical_files(struct hashmap *srcs,
                struct diff_filespec *source = p->filespec;
 
                /* False hash collision? */
-               if (hashcmp(source->sha1, target->sha1))
+               if (oidcmp(&source->oid, &target->oid))
                        continue;
                /* Non-regular files? If so, the modes must match! */
                if (!S_ISREG(source->mode) || !S_ISREG(target->mode)) {
@@ -462,7 +464,7 @@ void diffcore_rename(struct diff_options *options)
                                 strcmp(options->single_follow, p->two->path))
                                continue; /* not interested */
                        else if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&
-                                is_empty_blob_sha1(p->two->sha1))
+                                is_empty_blob_sha1(p->two->oid.hash))
                                continue;
                        else if (add_rename_dst(p->two) < 0) {
                                warning("skipping rename detection, detected"
@@ -472,7 +474,7 @@ void diffcore_rename(struct diff_options *options)
                        }
                }
                else if (!DIFF_OPT_TST(options, RENAME_EMPTY) &&
-                        is_empty_blob_sha1(p->one->sha1))
+                        is_empty_blob_sha1(p->one->oid.hash))
                        continue;
                else if (!DIFF_PAIR_UNMERGED(p) && !DIFF_FILE_VALID(p->two)) {
                        /*
@@ -535,7 +537,7 @@ void diffcore_rename(struct diff_options *options)
                                rename_dst_nr * rename_src_nr, 50, 1);
        }
 
-       mx = xcalloc(st_mult(num_create, NUM_CANDIDATE_PER_DST), sizeof(*mx));
+       mx = xcalloc(st_mult(NUM_CANDIDATE_PER_DST, num_create), sizeof(*mx));
        for (dst_cnt = i = 0; i < rename_dst_nr; i++) {
                struct diff_filespec *two = rename_dst[i].two;
                struct diff_score *m;