# sebastianbergmann/diff

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/sebastianbergmann-diff).**

7,663 stars · 87 forks · PHP · BSD-3-Clause

## Links

- GitHub: https://github.com/sebastianbergmann/diff
- awesome-repositories: https://awesome-repositories.com/repository/sebastianbergmann-diff.md

## Description

This is a sequence comparison library and text difference engine that implements the Myers diff algorithm to identify additions and deletions between two sequences of text or arrays. It functions as a tool for calculating the shortest edit script to determine exactly which elements were modified between two versions of a file.

The project provides a unified diff generator to produce standard textual representations of changes for human review, as well as a unified diff parser that converts these strings into structured objects for programmatic analysis.

The engine treats text inputs as arrays of lines or characters to allow generic comparison of any sequence. It utilizes graph search and linear space refinement to identify matching and differing segments.

## Tags

### Scientific & Mathematical Computing

- [Diff Algorithms](https://awesome-repositories.com/f/scientific-mathematical-computing/diff-algorithms.md) — Provides a full implementation of the Myers diff algorithm for computing optimal edit scripts.

### Artificial Intelligence & ML

- [Diff Graph Search](https://awesome-repositories.com/f/artificial-intelligence-ml/diff-graph-search.md) — Finds the shortest edit script by calculating the optimal path through a graph of possible edits.
- [Linear Space Refinement](https://awesome-repositories.com/f/artificial-intelligence-ml/search-space-definition/linear-space-refinement.md) — Reduces memory consumption during the search for optimal edits by splitting the comparison range.

### Development Tools & Productivity

- [Diff Data Parsers](https://awesome-repositories.com/f/development-tools-productivity/diff-data-parsers.md) — Converts unified diff strings into structured object graphs for programmatic analysis. ([source](https://github.com/sebastianbergmann/diff#readme))
- [Text Difference Computation](https://awesome-repositories.com/f/development-tools-productivity/text-object-selection/text-block-movement/text-difference-computation.md) — Identifies added, removed, or changed segments by calculating differences between text strings or arrays. ([source](https://github.com/sebastianbergmann/diff/tree/main/.phive))
- [Version Control](https://awesome-repositories.com/f/development-tools-productivity/developer-utilities-libraries/developer-tools/version-control-ecosystems/version-control.md) — Calculates the shortest edit script between two versions of a file to support version tracking.

### Software Engineering & Architecture

- [Sequence Comparison Algorithms](https://awesome-repositories.com/f/software-engineering-architecture/sequence-comparison-algorithms.md) — Implements sequence comparison algorithms to identify the minimal set of additions and deletions.
- [Difference Calculations](https://awesome-repositories.com/f/software-engineering-architecture/string-matching-algorithms/string-comparisons/difference-calculations.md) — Calculates the set of additions and removals between two sequences of strings.
- [Stateful Diff Parsing](https://awesome-repositories.com/f/software-engineering-architecture/unified-diff-formats/stateful-diff-parsing.md) — Converts raw unified diff text into structured objects by tracking metadata for headers and hunks.
- [Unified Diff Generators](https://awesome-repositories.com/f/software-engineering-architecture/unified-diff-formats/unified-diff-generators.md) — Creates a standard textual representation of changes between two pieces of text for human review.
- [Unified Diff Generation](https://awesome-repositories.com/f/software-engineering-architecture/unified-diff-generation.md) — Groups modified lines into contiguous hunks to produce a standard textual representation of changes.
- [Generic Sequence Comparison](https://awesome-repositories.com/f/software-engineering-architecture/generic-sequence-comparison.md) — Implements an array-based approach to allow generic comparison of any sequence of elements.

### Data & Databases

- [Document Diff Generators](https://awesome-repositories.com/f/data-databases/query-result-fetching/comparative-result-views/document-diff-generators.md) — Produces structured and visual representations of differences between two text sequences. ([source](https://github.com/sebastianbergmann/diff#readme))
