GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fuzzy patching does not account for earlier changes in line count · Issue #237 · java-diff-utils/java-diff-utils

Fuzzy patching does not account for earlier changes in line count #237

New issue
Copy link
New issue
Copy link
Closed
#238
Closed
Fuzzy patching does not account for earlier changes in line count#237
#238
Copy link

Description

@PHJ2000
PHJ2000
opened on Oct 5, 2026
Issue body actions

applyFuzzy(source, 0) can fail on the unchanged source after an earlier change reduces the line count:

import com.github.difflib.DiffUtils;
import com.github.difflib.patch.Patch;
import java.util.Arrays;
import java.util.List;
public class Reproduce {
 public static void main(String[] args) throws Exception {
  List<String> source=Arrays.asList("a","b","c","d","e");
  List<String> target=Arrays.asList("x","d","y");
  Patch<String> patch=DiffUtils.diff(source,target);
  System.out.println(patch.getDeltas());
  System.out.println("exact="+patch.applyTo(source));
  System.out.println("fuzzy="+patch.applyFuzzy(source,0));
 }
}

applyTo returns [x, d, y]. applyFuzzy throws IndexOutOfBoundsException with 4.17 and PatchFailedException with current master instead of returning the same result.

An expanding earlier change can also cause a later delta to modify a newly inserted matching line. lastPatchDelta only records the found position; it needs to include the difference between the target and source chunk sizes as well.

Activity

  1. wumpz
    closed this as completedin #238on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.