gliff/types
Shared type definitions for the gliff diffing library.
Import this module to access all types used in gliff’s public API.
Types
The diff algorithm to use.
pub type Algorithm {
Myers
Patience
}
Constructors
-
MyersMyers O(ND) algorithm — optimal edit distance, fast for similar texts.
-
PatiencePatience algorithm — anchors on unique lines for more readable output.
Post-processing cleanup mode to apply after diffing.
pub type Cleanup {
NoCleanup
SemanticCleanup
SemanticLosslessCleanup
}
Constructors
-
NoCleanupNo cleanup — return the raw diff result.
-
SemanticCleanupEliminate trivial equalities and merge adjacent edits.
-
SemanticLosslessCleanupShift edit boundaries to natural positions (word, sentence, line boundaries).
A conflict detected during 3-way merge where both sides modified the same region differently.
pub type Conflict {
Conflict(
base_lines: List(String),
our_lines: List(String),
their_lines: List(String),
)
}
Constructors
-
Conflict( base_lines: List(String), our_lines: List(String), their_lines: List(String), )Arguments
- base_lines
-
Lines from the base version in the conflicting region.
- our_lines
-
Lines from “ours” in the conflicting region.
- their_lines
-
Lines from “theirs” in the conflicting region.
A grouped edit operation representing one or more contiguous lines (or tokens) that share the same change type.
pub type Edit {
Equal(lines: List(String))
Insert(lines: List(String))
Delete(lines: List(String))
}
Constructors
-
Equal(lines: List(String))Lines present in both old and new text.
-
Insert(lines: List(String))Lines added in the new text.
-
Delete(lines: List(String))Lines removed from the old text.
A hunk in unified diff format, representing a localized group of changes with surrounding context lines.
pub type Hunk {
Hunk(
old_start: Int,
old_count: Int,
new_start: Int,
new_count: Int,
edits: List(Edit),
)
}
Constructors
-
Hunk( old_start: Int, old_count: Int, new_start: Int, new_count: Int, edits: List(Edit), )Arguments
- old_start
-
1-indexed starting line in the old file.
- old_count
-
Number of lines from the old file in this hunk.
- new_start
-
1-indexed starting line in the new file.
- new_count
-
Number of lines from the new file in this hunk.
- edits
-
The edit operations within this hunk.
The result of a 3-way merge operation.
pub type MergeResult {
MergeOk(merged: String)
MergeConflict(merged: String, conflicts: List(Conflict))
}
Constructors
-
MergeOk(merged: String)Merge completed without conflicts.
-
MergeConflict(merged: String, conflicts: List(Conflict))Merge has conflicts.
mergedcontains conflict markers,conflictslists each conflicting region.
A single-element edit produced by the diff algorithm internally.
Grouped into Edit before being returned to users.
pub type RawEdit {
RawEqual(value: String)
RawInsert(value: String)
RawDelete(value: String)
}
Constructors
-
RawEqual(value: String) -
RawInsert(value: String) -
RawDelete(value: String)