Repository navigation
fix: --path globs, --branch with --path, and dropped oldest commit - #19
Merged
Merged
Conversation
--path is passed to `git log -- <path>` as a Git pathspec, but validateOptions checked it as a regular expression, so globs like `src/**` were rejected. Validate it as a pathspec instead, reusing validatePathString (disallowed characters, traversal, length). The collector also put the branch after `--`, where git reads it as a second pathspec, so --branch was silently ignored whenever --path was set. The revision now comes before `--`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
git log emits the oldest commit last, and that record was parsed by the stream close handler, which treated the first newline as the end of the header. A multi-line commit body therefore looked like a header with too few fields, and the commit was silently dropped, so any range whose oldest commit had a detailed message lost one commit. Parse every record with one helper that ends the header at the first newline after the 7th field separator, both while streaming and at close. The regression test now asserts all 3 commits instead of >= 2, which had hidden the bug. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two bugs in the
--pathfilter.1. Globs were rejected.
--path "src/**"failed withPath pattern is not a valid regex pattern.validateOptionschecked the value as a regular expression, but the collector passes it togit log -- <path>as a Git pathspec, where**is a valid glob. It's never compiled or run as a regex, so the regex syntax and ReDoS checks guarded against nothing.validatePathString(disallowed shell/regex characters, directory traversal,//), keeping the 500-character limit.2.
--branchwas ignored when--pathwas set. The collector pushed the branch after--, so Git read it as a second pathspec and analyzed the current branch.--.Tests
validation.test.ts: the two regex-era tests are replaced by pathspec tests. Globs (src/**,src/core/*.ts,*.md,src/?ore) are accepted; disallowed characters, traversal, and over-long patterns are rejected; old regex-style inputs are still rejected (now as disallowed characters).collector-regression.test.ts: end-to-end on a temp repo. Adir/**glob keeps only the commits underdir/, and branch + path analyzes the requested branch.git-spark html --since 2026-07-01 --until 2026-09-30 --path "src/core/**"now succeeds and matches--path src/core.3. Oldest commit dropped (second commit)
With any range or path filter, the collector could return one commit fewer than
git log. Git prints the oldest commit last, and the stream-close handler took the first newline as the end of that record's header. When the oldest commit's message had a multi-line body, the header looked like it had too few fields and the commit was silently skipped.processRecordhelper parses every record, ending the header at the first newline after the 7th field separator, both while streaming and at close.>= 2of 3 commits, which hid the bug. It now asserts all 3, and a new test checks that commit's body and files. Both fail on the old code.git log --no-mergesexactly: unfiltered 221/221,src61/61 (was 60),v1.2.0+src/**46/46 (was 45),test50/50,docs55/55.All 345 tests pass.
🤖 Generated with Claude Code