Skip to content

feat: filter source tree by git-diff-branch changed files#313

Open
majiayu000 wants to merge 1 commit intomufeedvh:mainfrom
majiayu000:feat/issue-176-filter-tree-by-git-diff-branch
Open

feat: filter source tree by git-diff-branch changed files#313
majiayu000 wants to merge 1 commit intomufeedvh:mainfrom
majiayu000:feat/issue-176-filter-tree-by-git-diff-branch

Conversation

@majiayu000
Copy link
Copy Markdown

Fixes #176

When --git-diff-branch is set, source_tree and the collected file list now only include files that actually changed between the two branches. This cuts token count significantly for large repos where only a few files differ.

What changed:

git.rs — added get_git_diff_file_paths() which extracts changed file paths from diff.deltas(), covering both sides of renames.

configuration.rs — added diff_files: Option<HashSet<PathBuf>> to Code2PromptConfig so the changed-path set can flow through to traversal.

session.rsload_codebase() now computes diff_files before calling traverse_directory() when diff_branches is set.

path.rsdiscover_files() intersects each entry against diff_files when present, filtering both the tree display and the file content list. full_directory_tree still overrides tree filtering as before.

git_test.rs — test that creates a two-branch repo with modify/add/delete operations and verifies the returned paths.

Tested with cargo test --verbose, all existing + new tests pass.

When --git-diff-branch is used, only files that actually changed between
the two branches are now included in the source tree and file list.
This cuts token consumption by excluding unchanged files from the prompt.

Closes mufeedvh#176

Signed-off-by: majiayu000 <[email protected]>
@majiayu000 majiayu000 marked this pull request as ready for review March 31, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter source_tree for changed files when using --git-diff-branch

1 participant