X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=diffcore-rename.c;h=2e44a3745939bb75841730ba0cff78ea872df8d9;hb=dc4a1ba99c968d71ebe27c05c5a600e6df74e408;hp=749a35d2c2ab3271c6503a19271a5be6a6e97b4d;hpb=6293aea559b6c8f224f748e5a2a641ddb6cca55a;p=thirdparty%2Fgit.git diff --git a/diffcore-rename.c b/diffcore-rename.c index 749a35d2c2..2e44a37459 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -242,14 +242,12 @@ struct file_similarity { static unsigned int hash_filespec(struct diff_filespec *filespec) { - unsigned int hash; if (!filespec->sha1_valid) { if (diff_populate_filespec(filespec, 0)) return 0; hash_sha1_file(filespec->data, filespec->size, "blob", filespec->sha1); } - memcpy(&hash, filespec->sha1, sizeof(hash)); - return hash; + return sha1hash(filespec->sha1); } static int find_identical_files(struct hashmap *srcs, @@ -259,15 +257,14 @@ static int find_identical_files(struct hashmap *srcs, int renames = 0; struct diff_filespec *target = rename_dst[dst_index].two; - struct file_similarity *p, *best, dst; + struct file_similarity *p, *best = NULL; int i = 100, best_score = -1; /* * Find the best source match for specified destination. */ - best = NULL; - hashmap_entry_init(&dst, hash_filespec(target)); - for (p = hashmap_get(srcs, &dst, NULL); p; p = hashmap_get_next(srcs, p)) { + p = hashmap_get_from_hash(srcs, hash_filespec(target), NULL); + for (; p; p = hashmap_get_next(srcs, p)) { int score; struct diff_filespec *source = p->filespec;