summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/diff.h2
-rw-r--r--src/diff_tform.c33
2 files changed, 26 insertions, 9 deletions
diff --git a/src/diff.h b/src/diff.h
index a9a543ecd..ac8ab2aed 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -44,6 +44,8 @@ enum {
#define GIT_DIFF_FLAG__CLEAR_INTERNAL(F) (F) = ((F) & 0x00FFFF)
+#define GIT_DIFF__VERBOSE (1 << 30)
+
struct git_diff_list {
git_refcount rc;
git_repository *repo;
diff --git a/src/diff_tform.c b/src/diff_tform.c
index b481e64ce..0f4ecc7b5 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -828,22 +828,37 @@ int git_diff_find_similar(
if (similarity < (int)opts.rename_from_rewrite_threshold)
continue;
- memcpy(&swap, &from->new_file, sizeof(swap));
+ memcpy(&swap, &to->new_file, sizeof(swap));
- from->status = GIT_DELTA_RENAMED;
- from->similarity = (uint32_t)similarity;
- memcpy(&from->new_file, &to->new_file, sizeof(from->new_file));
- if ((from->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0) {
- from->flags &= ~GIT_DIFF_FLAG__TO_SPLIT;
+ to->status = GIT_DELTA_RENAMED;
+ to->similarity = (uint32_t)similarity;
+ memcpy(&to->new_file, &from->new_file, sizeof(to->new_file));
+ if ((to->flags & GIT_DIFF_FLAG__TO_SPLIT) != 0) {
+ to->flags &= ~GIT_DIFF_FLAG__TO_SPLIT;
num_rewrites--;
}
- memcpy(&to->new_file, &swap, sizeof(to->new_file));
- if ((to->flags & GIT_DIFF_FLAG__TO_SPLIT) == 0) {
- to->flags |= GIT_DIFF_FLAG__TO_SPLIT;
+ memcpy(&from->new_file, &swap, sizeof(from->new_file));
+ if ((from->flags & GIT_DIFF_FLAG__TO_SPLIT) == 0) {
+ from->flags |= GIT_DIFF_FLAG__TO_SPLIT;
num_rewrites++;
}
+ /* in the off chance that we've just swapped the new
+ * element into the correct place, clear the SPLIT flag
+ */
+ if (matches[matches[i].idx].idx == i &&
+ matches[matches[i].idx].similarity >
+ opts.rename_from_rewrite_threshold) {
+
+ from->status = GIT_DELTA_RENAMED;
+ from->similarity =
+ (uint32_t)matches[matches[i].idx].similarity;
+ matches[matches[i].idx].similarity = 0;
+ from->flags &= ~GIT_DIFF_FLAG__TO_SPLIT;
+ num_rewrites--;
+ }
+
num_updates++;
}
}