Skip to content

Keep blank context lines in multi-commit git log -p - #59

Merged
JayPokale merged 1 commit into
JayPokale:mainfrom
JYunth:fix/git-log-patch-context
Nov 27, 2026
Merged

JayPokale merged 1 commit into
JayPokale:mainfrom
JYunth:fix/git-log-patch-context

Conversation

@JYunth

@JYunth JYunth commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

What & why

With more than one commit, compactGitLog drops blank lines after each commit's message, but it tested !line.trim(). A blank context line in a patch is a single space, so git log -p -N lost every one of them and the hunks no longer matched their @@ counts. Nothing marks the cut, and an agent editing from that hunk works from the wrong text.

 // Stat block or patch (if any) follows.
-if (many && !lines[j].trim()) continue;
+if (many && lines[j] === '') continue;

git show (one commit) was not affected.

Evidence

  • Before (main at 4491077): git log -p -3 on this repo has 19 single-space context lines; the filtered output has 0. The new test fails.
  • After: every one kept (17 of 17 for the branch's own last three commits). The new test git log -p: several commits keep blank context lines in their hunks passes.

Checklist

  • skills/chisle/SKILL.md is the source of truth, with no rule logic duplicated into hooks
  • Regenerated rule copies + chart if behavior changed (no rule change; check:rules and check:chart clean)
  • Hook changes preserve the flag-file security model (O_NOFOLLOW, 0600) (untouched)
  • npm test passes (the new test and the rest of test_command_filters.js; six unrelated tests fail on macOS on main, fixed separately)
  • Added/updated a test for any hook logic change

Notes

Related to #57: its git log -3; cat notes.md case goes through the same line. The fix proposed there (filter only when every segment is recognised) would not cover this one, since git log -p -3 is a single recognised command.

Two-way door, one line. Blast radius: multi-commit git log/git log -p output only; whitespace-only lines between commits are now kept, so output can be a few lines longer.

compactGitLog drops blank lines between commits when the log has more
than one, but it tested !line.trim(), which also matches a patch's
blank context line (a single space). git log -p -3 on this repo lost
all 19 of them, so the hunks no longer matched their @@ counts. Only
truly empty lines are dropped now.
@JYunth
JYunth requested a review from JayPokale as a code owner November 26, 2026 14:07
@vercel

vercel Bot commented Nov 26, 2026

Copy link
Copy Markdown

@JYunth is attempting to deploy a commit to the jaypokale35gmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

@JayPokale
JayPokale merged commit 10fed7e into JayPokale:main Nov 27, 2026
3 of 4 checks passed
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