]> khamidou — GitHub mirrors - arcanist.git/commitdiff
There's an off-by-one derp issue with this.
authorepriestley <git@epriestley.com>
Tue, 8 Nov 2011 01:19:23 +0000 (17:19 -0800)
committerepriestley <git@epriestley.com>
Tue, 8 Nov 2011 01:19:23 +0000 (17:19 -0800)
src/parser/bundle/ArcanistBundle.php

index 5f997ca6d70247c4d07431c26aed64e0db6978b8..0b75ec85085bc947798f1c503fc6e07907bfabd4 100644 (file)
@@ -301,14 +301,14 @@ class ArcanistBundle {
       $last_change = $jj;
       for (; $jj < $n; ++$jj) {
         if ($lines[$jj][0] == ' ') {
-          // NOTE: We must use "context * 2" or we may generate overlapping
-          // hunks. For instance, if we have "context = 3" and four unchanged
-          // lines between hunks, we'll include unchanged lines 1, 2, 3 in
-          // the first hunk and 2, 3, and 4 in the second hunk -- that is, lines
-          // 2 and 3 will appear twice in the patch. Some time after 1.7.3.4,
-          // Git stopped cleanly applying patches with overlapping hunks, so be
-          // careful to avoid generating them.
-          if ($jj - $last_change > ($context * 2)) {
+          // NOTE: We must look past the context size or we may generate
+          // overlapping hunks. For instance, if we have "context = 3" and four
+          // unchanged lines between hunks, we'll include unchanged lines 1, 2,
+          // 3 in the first hunk and 2, 3, and 4 in the second hunk -- that is,
+          // lines 2 and 3 will appear twice in the patch. Some time after
+          // 1.7.3.4, Git stopped cleanly applying patches with overlapping
+          // hunks, so be careful to avoid generating them.
+          if ($jj - $last_change > (($context + 1) * 2)) {
             break;
           }
         } else {