fix(commit): madt_commit reports 0 files/insertions for a root (initial) commit #454
Labels
No labels
breaking
bug
documentation
enhancement
epic
good first issue
help wanted
refactoring
resolution/duplicate
resolution/invalid
resolution/wontfix
security
severity/critical
severity/high
severity/low
severity/medium
status/abandoned
status/blocked
status/needs-decision
status/needs-info
status/needs-verification
testing
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sixfold-space/madtea#454
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
madt_commitprints(0 file(s), +0 -0)for the FIRST commit in a brand-new repository, even when the commit contains files. The commit itself is correct; only the confirmation line is wrong, so a reader thinks nothing was committed.Repro
git inita fresh repo and write some files.madt_commit(files=[...], message="...")to make the first commit.Committed <sha> on <branch> (0 file(s), +0 -0): ....git show --stat <sha>shows every file is in the commit.Cause
internal/git/commit.go,GetCommitStats(line 39):git diff-tree --shortstat <ref>emits nothing for a root commit, because diff-tree compares a commit to its parent and a root commit has none. With empty output, thefiles changed/insertions/deletionsregexes match nothing andCommitStats{}stays all-zero.Fix
Add
--root, so diff-tree shows a parentless commit as a diff against the empty tree:Verified on a root commit:
--shortstatalone returns an empty string;--root --shortstatreturns the expectedN files changed, M insertions(+)line.--rootis a no-op for a commit that already has a parent, so it is safe for every case.Note
madt_commitalready special-cases the no-HEAD bootstrap repo for its default-branch guard, so this stat path just missed the same first-commit edge. Impact is display only; the commit content is never affected.