fix(commit): count files for a root commit with diff-tree --root #458

Merged
hexajon merged 1 commit from issue-454-root-commit-stats into main 2026-08-27 04:05:43 +00:00
Owner

Summary

madt_commit printed "(0 file(s), +0 -0)" for the first commit in a fresh repo, even when the commit contained files. git diff-tree --shortstat <ref> emits nothing for a root commit (it compares against a parent, and a root commit has none), so the stat regexes matched nothing and CommitStats stayed all-zero. Add --root so diff-tree shows a parentless commit as a diff against the empty tree; it is a no-op once a commit has a parent, so every other case is unchanged. The commit content was always correct - this fixes the confirmation line only. Adds TestGetCommitStats_RootCommit covering the root commit and a following non-root commit.

Closes #454

## Summary madt_commit printed "(0 file(s), +0 -0)" for the first commit in a fresh repo, even when the commit contained files. `git diff-tree --shortstat <ref>` emits nothing for a root commit (it compares against a parent, and a root commit has none), so the stat regexes matched nothing and CommitStats stayed all-zero. Add --root so diff-tree shows a parentless commit as a diff against the empty tree; it is a no-op once a commit has a parent, so every other case is unchanged. The commit content was always correct - this fixes the confirmation line only. Adds TestGetCommitStats_RootCommit covering the root commit and a following non-root commit. Closes #454
fix(commit): count files for a root commit with diff-tree --root (#454)
All checks were successful
drift / govulncheck (pull_request) Has been skipped
drift / surface-diff (pull_request) Successful in 1m7s
ci / mcp-conformance (push) Successful in 1s
drift / govulncheck (push) Has been skipped
drift / forgejo-smoke (push) Has been skipped
drift / forgejo-smoke (pull_request) Has been skipped
ci / mcp-conformance (pull_request) Successful in 1m47s
drift / surface-diff (push) Successful in 0s
ci / gate (push) Successful in 11m42s
ci / gate (pull_request) Successful in 18m18s
301ef4e6d3
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sixfold-space/madtea!458
No description provided.