refactor: update file_diff_contents to use git2 instead of CLI, make path helper more robust#283
Closed
Scott McMaster (scottmcmaster) wants to merge 4 commits into
Conversation
Collaborator
Author
This was referenced Jun 3, 2026
Contributor
📋 PR Overview
🔬 Coverage
|
Copilot started reviewing on behalf of
Scott McMaster (scottmcmaster)
June 3, 2026 03:16
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors Git file-content diff retrieval to use git2 (instead of spawning the Git CLI), while hardening repository-relative path handling and centralizing repo file helpers in a dedicated module.
Changes:
- Moved
file_diff_contentsinto thegit::query(git2-based) layer and updated the Tauri command to call it. - Added
git::repo_fileshelpers for lexical path normalization plus reading HEAD/workdir contents, with new unit tests. - Removed the old CLI-based
file_diff_contentsimplementation and its associated tests fromgit::exec.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| apps/native/src-tauri/src/git/repo_files.rs | New helper module for safe-ish repo-relative path normalization and reading file contents from HEAD/workdir, plus unit tests. |
| apps/native/src-tauri/src/git/query.rs | Adds git2-backed file_diff_contents and ports tests to the query layer. |
| apps/native/src-tauri/src/git/mod.rs | Registers the new repo_files module. |
| apps/native/src-tauri/src/git/exec.rs | Removes the old CLI-based file_diff_contents implementation and tests. |
| apps/native/src-tauri/src/commands/git.rs | Updates the command to use git::query::file_diff_contents. |
db44420 to
cef6666
Compare
7af395d to
5dc3c0e
Compare
cef6666 to
77ec990
Compare
5dc3c0e to
d12e1b6
Compare
77ec990 to
eebaeab
Compare
d12e1b6 to
b72b20e
Compare
3 tasks
b72b20e to
e7e9c8c
Compare
Juanpe Bolívar (arximboldi)
approved these changes
Jun 3, 2026
Juanpe Bolívar (arximboldi)
left a comment
Contributor
There was a problem hiding this comment.
Neat!
1af9231 to
9e77908
Compare
e7e9c8c to
9fbe45c
Compare
cooper (czxtm)
approved these changes
Jun 4, 2026
|
|
||
| /// Reads the contents of a file at the given path from the working directory of the repository. | ||
| /// Returns an empty string if the file does not exist on disk. | ||
| /// Symlinks are followed, but only if the resolved target remains inside the repository workdir. |
Member
There was a problem hiding this comment.
nice, leaving this as a note-to-self, as this just got me thinking about symlinks that DO cross the repository boundary, since it is pretty common to symlink files to e.g. ~/.config/code/settings.json to sync vs code settings across machines.
Contributor
Merge activity
|
…path helper more robust
…within the repository workdir and add tests for symlink behavior
5175c7c to
7b94871
Compare
452ba67 to
48f72d6
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Port
file_diff_contentsover to git2 in thequerysubmodule, also move associated tests. Create required new file operations in a newrepo_files.rsfile and add independent unit tests for them, Also make the path normalization helper more robust since the one that was there before looked like it might have a few robustness issues.Test Plan
Added and updated unit tests, run evolve manually to trigger the diffing command.
Docs
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.