mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-12-23 14:00:55 +01:00
Prevent ArcanistBundle from generating patches with overlapping hunks
Summary: We currently may generate patches which have hunks that include overlapping context. Git was okay with this until at least 1.7.3.4, but started rejecting these patches some time later. We already attempt to detect and prevent this condition, we just don't do a very good job of it. Fix the check so that we avoid generating overlapping hunks. Test Plan: - Cleanly applied troublesome patches under Git 1.7.7.2. - Used "arc export --git" to verify patches generate without overlapping sections. - Locally changed $context to 2 and 1, verified patch behavior was reasonable. Reviewers: kdeggelman, bizrad6, jonathanhester, jungejason, nh, tuomaspelkonen, aran CC: Differential Revision: 1084
This commit is contained in:
parent
42b69af59b
commit
cc3641e633
1 changed files with 8 additions and 1 deletions
|
@ -301,7 +301,14 @@ class ArcanistBundle {
|
|||
$last_change = $jj;
|
||||
for (; $jj < $n; ++$jj) {
|
||||
if ($lines[$jj][0] == ' ') {
|
||||
if ($jj - $last_change > $context) {
|
||||
// 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)) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue