Skip to main content

Crate sley_diff_merge

Crate sley_diff_merge 

Source

Modules§

range
Patch-series assignment for range-diff.
render
Unified-diff / patch RENDERER: turn a computed file diff (the old/new blob contents) into the textual unified-diff hunk body git’s diff.c emit path produces (emit_diff_symbol / fn_out_consume).
ws
Whitespace-rule engine — a port of git’s ws.c / ws.h.

Structs§

BString
A byte string for git paths and similar on-disk identifiers.
Conflict
DiffLine
A single line of a blob, slicing into the original buffer.
DiffNameStatusOptions
FilePatch
A patch targeting a single file. Produced by parse_unified_patch.
Hunk
A single @@ -old_start,old_len +new_start,new_len @@ hunk.
IndexGitlinkEntry
IndexWorktreeDiff
MergeBlobOptions
Labels and style controlling merge_blobs conflict markers.
MergeBlobResult
The outcome of a 3-way blob merge.
MergeStages
Per-stage higher-order index entries for a conflicted path.
MergeTreesOptions
Options controlling a merge_trees run.
MergeTreesResult
The outcome of a 3-way tree merge: the merged top-level tree plus per-path detail and a clean/conflicted flag.
MergedPath
One resolved/conflicted path in the merged tree.
NameStatusEntry
RenameDetectionOptions
Options controlling inexact (similarity-based) rename and copy detection, layered additively on top of DiffNameStatusOptions.
WsIgnore
Whitespace-ignore flags for line comparison, mirroring git’s XDF_WHITESPACE_FLAGS (-w, -b, --ignore-space-at-eol, --ignore-cr-at-eol). Only one of the whitespace flavours is honoured per git’s precedence (-w-b--ignore-space-at-eol--ignore-cr-at-eol); when several are set, the strongest wins, matching the cascade in xdl_recmatch.

Enums§

ApplyOutcome
Outcome of applying a FilePatch to a base buffer.
ConflictStyle
Which conflict-marker style merge_blobs emits.
DiffAlgorithm
DiffOp
A run-length entry in a Myers edit script.
DirectoryRenames
How directory-rename detection behaves, mirroring git’s merge.directoryRenames configuration.
FileChange
HunkLine
A single line inside a hunk. The stored bytes never include the trailing line terminator; whether the line is terminated by \n is tracked separately on the Hunk (see Hunk::old_no_newline / Hunk::new_no_newline) so the no-final-newline case can be reproduced byte-for-byte.
MergeConflictKind
The kind of conflict recorded for a path, used to render the stable conflict-type token and human message.
MergeFavor
Whether to favour one side wholesale for textual conflicts (-Xours / -Xtheirs), or to leave conflict markers in place.
MergeInfoMessage
Non-conflict merge information that porcelain commands may print.
NameStatus

Constants§

DEFAULT_RENAME_THRESHOLD
git’s default minimum similarity (as a percentage) for a pair of files to be reported as a rename or copy. Matches git’s built-in -M/-C threshold of 50% (DEFAULT_RENAME_SCORE is MAX_SCORE / 2).

Functions§

apply_file_patch
Apply a single-file patch to base, returning the patched bytes.
blob_similarity
Compute the content similarity of two blobs as an integer percentage in 0..=100, using git’s span-hash counting metric (see the module comment above for the exact definition).
count_changes
Sum, over every hash present in both maps, the smaller of the two byte counts. This is git’s src_copied: the number of bytes that appear on both sides (counting multiplicity via the per-hash byte totals). git diffcore_count_changes(): span-hash byte accounting between two blobs. Returns (src_copied, literal_added) — the bytes of src that survive into dst, and the bytes of dst not accounted for by src. --dirstat’s default “changes” damage is (src.len() - src_copied) + literal_added.
diff_lines_with_algorithm
Dispatch to the line-diff implementation selected by algorithm.
diff_name_status_empty_tree_with_options
diff_name_status_empty_tree_with_rename_options
Diff the empty tree against right_tree with full rename/copy options.
diff_name_status_head_index
diff_name_status_head_index_with_options
diff_name_status_head_index_with_rename_options
HEAD-vs-index name-status with full rename/copy options, including inexact (similarity) detection when enabled. All blob content (both sides) comes from the object database.
diff_name_status_head_worktree
diff_name_status_head_worktree_with_options
diff_name_status_head_worktree_with_rename_options
HEAD-vs-worktree name-status with full rename/copy options, including inexact (similarity) detection when enabled. Worktree blob content is read directly from the working tree; HEAD-side blobs come from the object database.
diff_name_status_index_worktree
diff_name_status_index_worktree_for_diff_files_with_options
Index-vs-worktree name-status for git diff-files (plumbing), which selects changed paths by the cached stat rather than by content.
diff_name_status_index_worktree_for_diff_files_with_rename_options
As diff_name_status_index_worktree_for_diff_files_with_options, but with full rename/copy options (the git diff-files -M/-C path). The stat-dirty augmentation is identical; only the underlying content diff differs.
diff_name_status_index_worktree_with_options
diff_name_status_index_worktree_with_options_and_gitlinks
diff_name_status_index_worktree_with_rename_options
Index-vs-worktree name-status with full rename/copy options, including inexact (similarity) detection when enabled. Worktree blob content is read directly from the working tree; index-side blobs come from the object database.
diff_name_status_index_worktree_with_rename_options_and_gitlinks
diff_name_status_tree_index_with_options
Name-status diff of an arbitrary tree against the index, the engine behind git diff-index --cached <tree-ish>. Exact rename/copy detection follows options; all blob content comes from the object database.
diff_name_status_tree_index_with_rename_options
Tree-vs-index name-status with full rename/copy options, including inexact (similarity) detection when enabled. Both sides read blob content from the object database. Counterpart of diff_name_status_head_index_with_rename_options for an arbitrary tree.
diff_name_status_tree_worktree_with_options
Name-status diff of an arbitrary tree against the working tree, the engine behind plain git diff-index <tree-ish> (no --cached). New-side oids for paths whose worktree contents differ from the index are cleared (rendered as zeros), matching git, which only reports the worktree blob oid when it is known-clean against the index.
diff_name_status_tree_worktree_with_rename_options
Tree-vs-worktree name-status with full rename/copy options, including inexact (similarity) detection when enabled. Worktree blob content is read directly from the working tree (via an oid-keyed cache); tree-side blobs come from the object database. As with diff_name_status_tree_worktree_with_options, new-side oids for paths that differ from the index are cleared.
diff_name_status_trees_with_options
diff_name_status_trees_with_rename_options
Diff two trees with full rename/copy options, including inexact (similarity) detection when RenameDetectionOptions::detect_inexact is set.
flatten_tree
Read a tree object (by oid) into a flattened path -> (mode, oid) map, descending into subtrees. The canonical empty tree yields an empty map.
gitlink_git_dir
Resolve the git directory of an embedded repository whose working tree is at sub_root. A .git directory is returned as-is; a .git file is followed through its gitdir: <path> pointer (a relative pointer resolves against sub_root). Returns None when there is no .git entry or the pointer does not name an existing directory.
gitlink_head_oid
Resolve the commit checked out in the embedded repository at sub_root (the value a gitlink entry for that path records): its git directory’s HEAD, followed through symbolic refs. None when sub_root is not a repository or its HEAD does not resolve to a commit (e.g. an unborn branch) — upstream’s resolve_gitlink_ref() < 0 case.
histogram_diff_lines
Compute a line-level edit script transforming old into new using the histogram diff algorithm (as in git diff --histogram, derived from JGit).
is_mergeable_file_mode
True for a plain file blob (regular or executable) — i.e. a mode whose content can be textually 3-way merged. Symlinks and gitlinks are excluded.
merge_blobs
Perform a 3-way merge of three blobs using the diff3 algorithm.
merge_entry_maps
merge_trees operating on already-flattened entry maps. The merge porcelains often hold the flattened maps already (e.g. cherry-pick builds theirs from a picked commit’s tree), so this avoids re-reading them.
merge_trees
3-way merge of three trees into a single merged tree.
myers_diff_lines
Compute a minimal line-level edit script transforming old into new using Myers’ O(ND) difference algorithm.
myers_diff_lines_ws
Compute a line-level edit script transforming old into new, comparing lines under the whitespace-ignore flags ignore while the returned ops still index the original lines position-for-position.
parse_unified_patch
Parse a unified/git diff into one FilePatch per file it touches.
parse_unified_patch_with_recount
Parse a unified/git diff, optionally ignoring hunk header line counts and recounting them from the hunk body. This mirrors git apply --recount.
patience_diff_lines
Compute a line-level edit script transforming old into new using the patience diff algorithm (Bram Cohen’s algorithm, as in git diff --patience).
split_lines
Split a blob into lines, preserving the exact bytes of each line.

Type Aliases§

MergeEntryMap
Flattened tree: repository-relative path -> (mode, blob/symlink/gitlink oid).