Skip to content

fix(git): git_log date-filtered path misparses every commit after the first#4491

Open
tao-hpu wants to merge 1 commit into
modelcontextprotocol:mainfrom
tao-hpu:fix-git-log-date-filter
Open

fix(git): git_log date-filtered path misparses every commit after the first#4491
tao-hpu wants to merge 1 commit into
modelcontextprotocol:mainfrom
tao-hpu:fix-git-log-date-filter

Conversation

@tao-hpu

@tao-hpu tao-hpu commented Jul 7, 2026

Copy link
Copy Markdown

Bug

git_log with start_timestamp/end_timestamp uses --format=%H%n%an%n%ad%n%s%n. The trailing %n, plus the newline git prints between log entries, makes each commit emit 5 lines, while the parser walks the output in strides of 4 (server.py, for i in range(0, len(log_output), 4)). Alignment breaks from the second commit on.

Actual output on a 3-commit repo with start_timestamp="2000-01-01":

Commit: 15d3a078...          <- commit 3, correct
...
Commit:                      <- blank: this is the separator line
Author: 36688c31c43d9bb...   <- the hash landed in the author column
Date: T                      <- the author landed in the date column
Message: Wed Jul 8 01:04:18  <- the date landed in the message column

Fix

Drop the trailing %n so each commit is exactly 4 lines. One-character change; the non-filtered path is untouched.

Tests

The date-filtered path had no coverage (test_git_log/test_git_log_default only exercise the plain path). Added test_git_log_with_date_filter, which asserts per-field alignment for every returned entry. Verified it fails on the old format string and passes with the fix. Full suite: 44 passed.

🤖 Generated with Claude Code

… first

The --format string ended with a trailing %n. Together with the newline
git prints between log entries, each commit emitted 5 lines while the
parser walks the output in strides of 4, so field alignment broke from
the second commit on (hash column blank, author column holding the
hash, and so on). Drop the trailing %n so each commit is exactly 4
lines, and add a regression test covering the date-filtered path, which
previously had no coverage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant