aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
diff options
context:
space:
mode:
authorKB Sriram <kbsriram@google.com>2017-03-22 11:42:38 -0700
committerKB Sriram <kbsriram@google.com>2017-04-03 16:45:13 -0700
commit4a985f5aa858a71561d55c9eb3ce007768c4d0c0 (patch)
tree8c0020ca1999be62213bea84b0655e493fe7269d /org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
parent61e336475db27cb11cc370a9947bf6529e34daa0 (diff)
downloadjgit-4a985f5aa858a71561d55c9eb3ce007768c4d0c0.tar.gz
jgit-4a985f5aa858a71561d55c9eb3ce007768c4d0c0.zip
Make diff locations more consistent
DiffAlgorithms can return different edit locations for inserts or deletes, if they can be "shifted" up or down repeating blocks of lines. This causes the 3-way merge to apply both edits, resulting in incorrectly removing or duplicating lines. Augment an existing "tidy-up" stage in DiffAlgorithm to move all shiftable edits (not just the last INSERT edit) to a consistent location, and add test cases for previously incorrect merges. Bug: 514095 Change-Id: I5fe150a2fc04e1cdb012d22609d86df16dfb0b7e Signed-off-by: KB Sriram <kbsriram@google.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
index 7eecd13513..3ac46ea121 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/Edit.java
@@ -170,6 +170,20 @@ public class Edit {
}
/**
+ * Move the edit region by the specified amount.
+ * @param amount
+ * the region is shifted by this amount, and can be
+ * positive or negative.
+ * @since 4.7
+ */
+ public final void shift(int amount) {
+ beginA += amount;
+ endA += amount;
+ beginB += amount;
+ endB += amount;
+ }
+
+ /**
* Construct a new edit representing the region before cut.
*
* @param cut