Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-10-19 07:34:02 +0300
committerJunio C Hamano <gitster@pobox.com>2018-10-19 07:34:02 +0300
commit11877b9ebec87175a9cc55676311ef2d98585cca (patch)
tree4dbcd834daeedc9373f368e67fa0fcdf5e52359c /diffcore-rename.c
parentaef8e71f1512c2edb1b323969d3f215a23ff1c04 (diff)
parentb3c7eef9b0581f06be67418f130d33d7a7c490cb (diff)
Merge branch 'nd/the-index'
Various codepaths in the core-ish part learn to work on an arbitrary in-core index structure, not necessarily the default instance "the_index". * nd/the-index: (23 commits) revision.c: reduce implicit dependency the_repository revision.c: remove implicit dependency on the_index ws.c: remove implicit dependency on the_index tree-diff.c: remove implicit dependency on the_index submodule.c: remove implicit dependency on the_index line-range.c: remove implicit dependency on the_index userdiff.c: remove implicit dependency on the_index rerere.c: remove implicit dependency on the_index sha1-file.c: remove implicit dependency on the_index patch-ids.c: remove implicit dependency on the_index merge.c: remove implicit dependency on the_index merge-blobs.c: remove implicit dependency on the_index ll-merge.c: remove implicit dependency on the_index diff-lib.c: remove implicit dependency on the_index read-cache.c: remove implicit dependency on the_index diff.c: remove implicit dependency on the_index grep.c: remove implicit dependency on the_index diff.c: remove the_index dependency in textconv() functions blame.c: rename "repo" argument to "r" combine-diff.c: remove implicit dependency on the_index ...
Diffstat (limited to 'diffcore-rename.c')
-rw-r--r--diffcore-rename.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/diffcore-rename.c b/diffcore-rename.c
index daddd9b28a..07bd34b631 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -128,7 +128,8 @@ struct diff_score {
short name_score;
};
-static int estimate_similarity(struct diff_filespec *src,
+static int estimate_similarity(struct repository *r,
+ struct diff_filespec *src,
struct diff_filespec *dst,
int minimum_score)
{
@@ -165,10 +166,10 @@ static int estimate_similarity(struct diff_filespec *src,
* say whether the size is valid or not!)
*/
if (!src->cnt_data &&
- diff_populate_filespec(src, CHECK_SIZE_ONLY))
+ diff_populate_filespec(r, src, CHECK_SIZE_ONLY))
return 0;
if (!dst->cnt_data &&
- diff_populate_filespec(dst, CHECK_SIZE_ONLY))
+ diff_populate_filespec(r, dst, CHECK_SIZE_ONLY))
return 0;
max_size = ((src->size > dst->size) ? src->size : dst->size);
@@ -186,12 +187,12 @@ static int estimate_similarity(struct diff_filespec *src,
if (max_size * (MAX_SCORE-minimum_score) < delta_size * MAX_SCORE)
return 0;
- if (!src->cnt_data && diff_populate_filespec(src, 0))
+ if (!src->cnt_data && diff_populate_filespec(r, src, 0))
return 0;
- if (!dst->cnt_data && diff_populate_filespec(dst, 0))
+ if (!dst->cnt_data && diff_populate_filespec(r, dst, 0))
return 0;
- if (diffcore_count_changes(src, dst,
+ if (diffcore_count_changes(r, src, dst,
&src->cnt_data, &dst->cnt_data,
&src_copied, &literal_added))
return 0;
@@ -256,10 +257,11 @@ struct file_similarity {
struct diff_filespec *filespec;
};
-static unsigned int hash_filespec(struct diff_filespec *filespec)
+static unsigned int hash_filespec(struct repository *r,
+ struct diff_filespec *filespec)
{
if (!filespec->oid_valid) {
- if (diff_populate_filespec(filespec, 0))
+ if (diff_populate_filespec(r, filespec, 0))
return 0;
hash_object_file(filespec->data, filespec->size, "blob",
&filespec->oid);
@@ -280,7 +282,9 @@ static int find_identical_files(struct hashmap *srcs,
/*
* Find the best source match for specified destination.
*/
- p = hashmap_get_from_hash(srcs, hash_filespec(target), NULL);
+ p = hashmap_get_from_hash(srcs,
+ hash_filespec(options->repo, target),
+ NULL);
for (; p; p = hashmap_get_next(srcs, p)) {
int score;
struct diff_filespec *source = p->filespec;
@@ -316,14 +320,16 @@ static int find_identical_files(struct hashmap *srcs,
return renames;
}
-static void insert_file_table(struct hashmap *table, int index, struct diff_filespec *filespec)
+static void insert_file_table(struct repository *r,
+ struct hashmap *table, int index,
+ struct diff_filespec *filespec)
{
struct file_similarity *entry = xmalloc(sizeof(*entry));
entry->index = index;
entry->filespec = filespec;
- hashmap_entry_init(entry, hash_filespec(filespec));
+ hashmap_entry_init(entry, hash_filespec(r, filespec));
hashmap_add(table, entry);
}
@@ -344,7 +350,9 @@ static int find_exact_renames(struct diff_options *options)
*/
hashmap_init(&file_table, NULL, NULL, rename_src_nr);
for (i = rename_src_nr-1; i >= 0; i--)
- insert_file_table(&file_table, i, rename_src[i].p->one);
+ insert_file_table(options->repo,
+ &file_table, i,
+ rename_src[i].p->one);
/* Walk the destinations and find best source match */
for (i = 0; i < rename_dst_nr; i++)
@@ -557,7 +565,8 @@ void diffcore_rename(struct diff_options *options)
diff_unmodified_pair(rename_src[j].p))
continue;
- this_src.score = estimate_similarity(one, two,
+ this_src.score = estimate_similarity(options->repo,
+ one, two,
minimum_score);
this_src.name_score = basename_same(one, two);
this_src.dst = i;