Skip to content

A range is read with one git log: two git processes for a range, in place of twenty more a commit - #91

Merged
closer-claudio merged 1 commit into
mainfrom
claudio/20261115-one-git-log
Nov 16, 2026
Merged

closer-claudio merged 1 commit into
mainfrom
claudio/20261115-one-git-log

Conversation

@closer-claudio

Copy link
Copy Markdown

🎯 Why

git.Commits listed a range with git rev-list, then asked git for each commit one field at a time: twenty git log -1 --pretty=format:<field> a commit, one for every key of FieldNames. A range of n commits started 2 + 20n gits before any rule ran.

🛠️ What

git/commits.go: a new entries reads every field of every commit of the range from one git log, the formats joined by a NUL and -z for a NUL between commits. No field holds a NUL, so a body is read whole whatever its lines. Each field is trimmed and its CRLF folded, as before. LogCommit is the same reader with -1.

A range now starts two gits whatever its length: the one that checks it resolves, and the log.

One thing changes besides the count. With log.showSignature set, git prints what it found of a signature ahead of each commit it shows. The old reader showed a commit twenty times, so every field of a signed commit began with that line: its subject read Good "git" signature for ..., then the subject, and the commit failed its rules. The new call passes --no-show-signature, and no field holds the line; the signature stays in the fields that ask for it (%G?, %GS, %GK).

🧪 How

  1. Measured with the command built before and after, over the 236 commits of b3d5ea7~100..b3d5ea7 in this repository, -D counting the gits: 5194 before, 474 after (the two for the range, and two a commit that the whitespace rule still starts); 219 s and 22 s on the same machine. The verbose report is the same byte for byte, 945 lines, and the exit status the same. Field for field, a probe compared what the new reader gives with one git log -1 a field: 4720 fields of those commits, none differs.

    Tests: TestCommitsRunsTwoGitsWhateverTheRange counts the gits of a range of one commit and of five: two each (22 and 102 against the package as it was). TestContractLogCommitIsGitsView gains a commit whose message git did not clean, which nothing held: its CRLF is folded. TestContractASignedCommitIsReadAsWritten signs a commit with a key made in the test, sets log.showSignature, and reads it both ways: the fields are as written and none holds git's line; against the reader as it was, all twenty do.

    Broken on purpose, each alone, and each fails a test: the CRLF kept; a newline between commits in place of the NUL; the fields given to the wrong names; --no-show-signature left out.

V: just lint and just test green on the branch (64 tests; the signed-commit test needs ssh-keygen and skips without it).

📝 Notes

For #50.

Commits listed a range with git rev-list and then asked git for each
commit one field at a time: twenty `git log -1 --pretty=format:<field>`
a commit, one for every key of FieldNames. A range of n commits started
2 + 20n gits before any rule ran.

entries reads every field of every commit of the range from one
`git log`: the formats joined by a NUL, and `-z` for a NUL between
commits. No field holds a NUL, so a body is read whole whatever its
lines. Each field is trimmed and its CRLF folded as before. LogCommit
is the same reader with `-1`. A range now starts two gits whatever its
length: the one that checks it resolves, and the log.

One thing changes besides the count. With log.showSignature set, git
prints what it found of a signature ahead of each commit it shows. The
old reader showed a commit twenty times, so every field of a signed
commit began with that line: its subject read `Good "git" signature
for ...`, then the subject. Nobody can have run with that setting, as
every subject would have failed. One log would leave the line in the
first field alone; the call passes --no-show-signature, and no field
holds it. The signature stays where it belongs, in the fields that ask
for it (%G?, %GS, %GK).

Measured with the command built before and after, over the 236 commits
of b3d5ea7~100..b3d5ea7 in this repository, `-D` counting the gits:
5194 before, 474 after (the two for the range, and two a commit that
the whitespace rule still starts); 219 s and 22 s on the same machine.
The verbose report is the same byte for byte, 945 lines, and the exit
status the same. Field for field, a probe compared what the new reader
gives with one `git log -1` a field, as before: 4720 fields of those
236 commits, none differs.

TestCommitsRunsTwoGitsWhateverTheRange counts the gits of a range of
one commit and of five: two each; against the package as it was, 22
and 102. TestContractLogCommitIsGitsView gains a commit whose message
git did not clean, which nothing held: its CRLF is folded.
TestContractASignedCommitIsReadAsWritten signs a commit with a key
made in the test, sets log.showSignature, and reads it both ways: the
fields are as written and none holds the line; against the reader as
it was, all twenty do. Broken on purpose, each alone: the CRLF kept; a
newline between commits in place of the NUL; the fields given to the
wrong names; --no-show-signature left out. Each fails a test.

For #50.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: closer-claudio <claudio@farcloser.world>
@closer-claudio
closer-claudio force-pushed the claudio/20261115-one-git-log branch from d5f337d to 7367299 Compare November 16, 2026 03:06
@closer-claudio

Copy link
Copy Markdown
Author

Reviewed at 7367299

1 similar comment
@closer-claudio

Copy link
Copy Markdown
Author

Reviewed at 7367299

@closer-claudio
closer-claudio merged commit 477924a into main Nov 16, 2026
14 checks passed
@closer-claudio
closer-claudio deleted the claudio/20261115-one-git-log branch November 16, 2026 04:32
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.

2 participants