Skip to content

Add git_diff_tree() for working tree diff against arbitrary revisions#12

Merged
teaguesterling merged 1 commit intomainfrom
issue/10-working-tree-diff
Mar 5, 2026
Merged

Add git_diff_tree() for working tree diff against arbitrary revisions#12
teaguesterling merged 1 commit intomainfrom
issue/10-working-tree-diff

Conversation

@teaguesterling
Copy link
Owner

Summary

  • Adds git_diff_tree() table function that compares the working tree against any git revision (not just HEAD), closing the gap identified in Working tree diff: detect modified files relative to a git revision #10
  • Uses libgit2's git_diff_tree_to_workdir_with_index for accurate change detection including rename/copy tracking
  • Includes LATERAL variant git_diff_tree_each() for multi-repo workflows

API

FROM git_diff_tree();                    -- workdir vs HEAD
FROM git_diff_tree('.', 'v1.0');         -- workdir vs arbitrary ref
FROM git_diff_tree(untracked:=true);     -- include untracked files

Returns: repo_path, file_path, file_ext, status (added/deleted/modified/renamed/copied/typechange), old_path

Test plan

  • Zero-arg, single-arg, and two-arg overloads return correct schema (5 columns)
  • Comparing against HEAD matches zero-arg default
  • Comparing against older refs returns more changes
  • untracked:=true includes untracked files
  • Status values are constrained to expected set
  • Existing test suite unaffected

Closes #10

🤖 Generated with Claude Code

…ns (#10)

Adds git_diff_tree() table function that uses libgit2's diff API to detect
modified, added, deleted, renamed, and copied files between the working tree
and any git revision. Includes LATERAL variant git_diff_tree_each().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@teaguesterling
Copy link
Owner Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@teaguesterling teaguesterling merged commit 8eaecb1 into main Mar 5, 2026
20 of 22 checks passed
@teaguesterling teaguesterling deleted the issue/10-working-tree-diff branch March 5, 2026 15:50
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.

Working tree diff: detect modified files relative to a git revision

1 participant