Main exports
Read inputs
FilePair stores old_path, new_path, old_source: Vec<u8>, new_source: Vec<u8>, old_exists, and new_exists. Empty bytes do not imply a missing file.
Repository inputs
GitRepository::discover(cwd)finds the repository root.root()returns its path.resolve_ref(reference)resolves a commit or returnsNonefor an unresolved ref.diff_working_tree_stream()yields fallible file pairs against HEAD.diff_commit_range_stream(range)yields pairs from a Git range.diff_working_tree()anddiff_commit_range(range)collect those streams.
Direct files and directories
read_file_pair(old_path, new_path) compares two files, following symbolic links to their contents. diff_directories_stream(old, new) yields directory pairs; diff_directories collects them. is_directory(path) checks an input path. Walks skip a fixed set of generated/vendor directories before descending, including .git, node_modules, target, dist, build, and vendor. Git and directory inputs preserve symbolic-link target text.
Git driver
diff_driver_command(executable, args) quotes a command for Git’s external-diff shell. DRIVER_FLAG is the internal entry flag. generate_git_attributes(extensions) creates attribute rules.
repo.install_git_driver(command) configures the local repository. repo.write_git_attributes(extensions) updates rules while preserving unrelated lines. The CLI command differens install-git-driver performs these changes explicitly and records the current executable path. Reinstall the driver after moving that binary.
The installer removes obsolete diff.differens.textconv and
diff.differens.cachetextconv settings. To uninstall, unset
diff.differens.command and remove diff=differens attributes while keeping the
rest of each rule. See Git integration.
Working tree and commit-range usage
How the Git driver works
Git’s external driver receives seven arguments:path is the original file path. The old/new file arguments are temporary blob
files, whose names may lack extensions. Driver mode uses the original path to
select the parser and reads those temporary files directly. Standalone repository
comparisons use batched Git blob reads instead; they do not invoke the driver for
each file.
To register a native command through the Rust API:
Removing the driver
diff=differens attributes you installed while preserving other rules.
If obsolete textconv or cachetextconv settings remain from a previous version,
unset those local keys too. An absent key can make git config --unset-all return
nonzero; it does not mean that a driver remains installed.