]> source.dussan.org Git - jgit.git/commitdiff
Fix diff bug on inserted line 35/3435/1
authorShawn O. Pearce <spearce@spearce.org>
Mon, 16 May 2011 18:28:23 +0000 (11:28 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 16 May 2011 18:28:23 +0000 (11:28 -0700)
For the following patch on the linux 2.6.32 tag:
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -685,6 +685,7 @@ static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sc

 static void check_spread(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
+#if 0
 #ifdef CONFIG_SCHED_DEBUG
        s64 d = se->vruntime - cfs_rq->min_vruntime;

@@ -694,6 +695,7 @@ static void check_spread(struct cfs_rq *cfs_rq, struct
sched
        if (d > 3*sysctl_sched_latency)
                schedstat_inc(cfs_rq, nr_spread_over);
 #endif
+#endif
 }

 static void

JGit produced an incorrect diff, attempting to add a new "}" instead
of the new "#endif" at the end of the hunk. This was caused by a prior
fix for bug 328895 where we wanted to "slide" a diff down in the file
when adding a new method/function and want to show the closing curly
brace as being added after the new method, rather than added onto the
end of the prior function or method just before the insertion point.

Bug: 345956
Change-Id: I32b9e24f1e2980258b1b39dd1807919ab1c5f9b2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java
org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffAlgorithm.java

index 85b5eb7c0befcb8990c7e913e5886dfc4129b379..b8f8dcb5ad096cc8f39d9ba240c29a8a22edbbcf 100644 (file)
@@ -191,7 +191,15 @@ public abstract class AbstractDiffTestCase {
        public void testEdit_InsertNearCommonTail() {
                EditList r = diff(t("aq}nb"), t("aCq}nD}nb"));
                assertEquals(new Edit(1, 1, 1, 2), r.get(0));
-               assertEquals(new Edit(3, 3, 4, 7), r.get(1));
+               assertEquals(new Edit(4, 4, 5, 8), r.get(1));
+               assertEquals(2, r.size());
+       }
+
+       @Test
+       public void testEdit_LinuxBug() {
+               EditList r = diff(t("a{bcdE}z"), t("a{0bcdEE}z"));
+               assertEquals(new Edit(2, 2, 2, 3), r.get(0));
+               assertEquals(new Edit(6, 6, 7, 8), r.get(1));
                assertEquals(2, r.size());
        }
 
index b20e3258b6ce2a20daec20e6ae2d8a5a41c15d99..96f4d1185753382c73653a2072a2299707ebc0fa 100644 (file)
@@ -126,7 +126,7 @@ public abstract class DiffAlgorithm {
                        Edit last = e.get(e.size() - 1);
                        if (last.getType() == Edit.Type.INSERT) {
                                while (last.endB < b.size()
-                                               && cmp.equals(b, last.beginB, b, region.endB)) {
+                                               && cmp.equals(b, last.beginB, b, last.endB)) {
                                        last.beginA++;
                                        last.endA++;
                                        last.beginB++;