From a0d12c4433e25e87b67df78b45635df8a098fb23 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Fri, 24 Jun 2016 23:09:23 +0000 Subject: diff: convert struct diff_filespec to struct object_id Convert struct diff_filespec's sha1 member to use a struct object_id called "oid" instead. The following Coccinelle semantic patch was used to implement this, followed by the transformations in object_id.cocci: @@ struct diff_filespec o; @@ - o.sha1 + o.oid.hash @@ struct diff_filespec *p; @@ - p->sha1 + p->oid.hash Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- diffcore-rename.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'diffcore-rename.c') diff --git a/diffcore-rename.c b/diffcore-rename.c index 7f03eb5a04..22b239a43a 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -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->sha1_valid, + two->mode); rename_dst[first].pair = NULL; return 0; } @@ -263,9 +264,10 @@ static unsigned int hash_filespec(struct diff_filespec *filespec) if (!filespec->sha1_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, @@ -287,7 +289,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)) { @@ -466,7 +468,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" @@ -476,7 +478,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)) { /* -- cgit v1.2.3