fix(git): empty `git log` range emits a blank line instead of empty output — breaks `| wc -l` counting
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start by reproducing rtk git log --oneline HEAD..HEAD and rtk proxy git log --oneline HEAD..HEAD, comparing their byte output with raw git. Trace the git log filtering entry point and add coverage for an empty range while preserving the existing non-empty behavior. Done means the empty range emits 0 bytes, so | wc -l reports 0.
Written by the indexing model from the issue text.
Description
Summary
When a git log range contains zero commits, rtk's filter emits a single blank line (\n, 1 byte) where raw git emits nothing (0 bytes). Any consumer that counts lines — the classic | wc -l — reads 1 instead of 0.
Minimal repro
$ rtk git log --oneline HEAD..HEAD | od -c
0000000 \n
0000001
$ rtk proxy git log --oneline HEAD..HEAD | od -c
$ # empty, as raw git
Non-empty ranges are filtered correctly.
Why it matters for rtk's audience
rtk's primary users are LLM coding agents, and git log <upstream>..HEAD | wc -l is the idiomatic "how many unpushed commits" check they emit constantly. Under the hook, a compound command starting with a rewritten command (e.g. git push … ; git log … | wc -l) goes through the filter and the agent concludes "1 unpushed commit" on a fully pushed branch — then wastes turns re-pushing or investigating phantom state. That's how we found it.
Workarounds we use meanwhile: git rev-list --count <range> (emits a number, not lines) or rtk proxy git log ….
Environment
- rtk 0.42.3 (Homebrew), macOS (Darwin 27.0.0)
- Changelog through v0.44.1 shows no related fix, and no existing issue matches (closest: #2305, #3028 — commit-dropping in non-empty logs, different defect).
Expected
Empty range in → empty output out (0 bytes), matching raw git.
- Dominant language
- Rust
- Stars
- 81.1k
- Forks
- 5.1k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 40
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rtk-ai/rtk
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
bug core output-formatting
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
uv_cmd discards print_with_hint's return value, so the tee hint is not counted and savings read 100% Openanalytics bug python
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
area:cli bug good first issue platform:windows priority:medium resolved-pending-close
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
area:cli bug good first issue priority:high
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
A-linter
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oxc-project/oxc#26863 ·