Skip to content

fix: respect user-specified git log limits (#461)#505

Merged
pszymkowiak merged 2 commits intortk-ai:developfrom
ousamabenyounes:fix/git-log-truncation
Mar 11, 2026
Merged

fix: respect user-specified git log limits (#461)#505
pszymkowiak merged 2 commits intortk-ai:developfrom
ousamabenyounes:fix/git-log-truncation

Conversation

@ousamabenyounes
Copy link
Copy Markdown
Contributor

Summary

Fixes #461rtk git log --oneline silently truncates output to 10 entries regardless of user intent.

Root cause: Two layers of truncation were fighting each other:

  1. run_log() injected -10 when no -N flag was present (even with --oneline)
  2. filter_log_output() applied .take(limit) again, re-capping even when the user explicitly passed -N
  3. Lines >80 chars were truncated, hiding PR numbers and full author names

Why this matters for LLM workflows:

  • git log --oneline -30 for rebase/squash: only got 10 commits, forcing re-runs
  • git log --oneline for changelog: silently incomplete history
  • PR numbers like (#473) and author names were truncated at 80 chars

Changes

Scenario Before After
rtk git log --oneline (no -N) 10 entries 50 entries
rtk git log -20 20 entries (but re-truncated) 20 entries (no re-truncation)
rtk git log (no flags) 10 entries 10 entries (unchanged)
Line truncation with explicit -N 80 chars 120 chars

Before/After

# BEFORE: --oneline silently capped at 10
$ rtk git log --oneline | wc -l
10

# AFTER: --oneline returns 50 (sensible default for compact format)
$ rtk git log --oneline | wc -l
50

# BEFORE: -20 truncated lines at 80 chars
cc93afc chore(master): release 0.28.2 (#473) (17 hours ago) <github-actions[b...

# AFTER: -20 uses 120-char threshold (preserves PR numbers + authors)
cc93afc chore(master): release 0.28.2 (#473) (17 hours ago) <github-actions[bot]>

Test plan

  • 2 new unit tests: test_filter_log_output_user_limit_no_cap, test_filter_log_output_user_limit_wider_truncation
  • All 7 filter_log_output tests pass
  • Full suite: 766 passed, 0 failed
  • Manual verification: --oneline, -20, default (no flags)
  • cargo fmt && cargo clippy && cargo test all green

Generated with Claude Code

@pszymkowiak pszymkowiak changed the base branch from master to develop March 11, 2026 19:04
…ting

RTK was silently capping git log output in two ways:
1. `--oneline` without `-N` defaulted to 10 entries (now 50)
2. `filter_log_output()` re-truncated even when user explicitly set `-N`
3. Lines >80 chars were truncated, hiding PR numbers and author names

This matters for LLM workflows: Claude needs full commit history for
rebase, squash, and changelog operations. Silent truncation caused
incomplete context and repeated re-runs.

Changes:
- User-explicit `-N` → no line cap, wider 120-char truncation
- `--oneline`/`--pretty` without `-N` → default 50 (was 10)
- No flags → unchanged (default 10)
- Extract `truncate_line()` helper for clarity

Fixes rtk-ai#461

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pszymkowiak pszymkowiak force-pushed the fix/git-log-truncation branch from 3098ec7 to 07901c8 Compare March 11, 2026 19:05
- Extract parse_user_limit() to handle all 4 forms: -20, -n 20, --max-count=20, --max-count 20
- Add token savings test for filter_log_output (≥60%)
- Add 5 tests for parse_user_limit edge cases

Signed-off-by: Patrick <patrick@rtk-ai.com>
Signed-off-by: Patrick szymkowiak <patrick.szymkowiak@innovtech.eu>
@pszymkowiak
Copy link
Copy Markdown
Collaborator

Thanks @ousamabenyounes! The user_set_limit approach is clean and the unicode fix with chars().count() is a real improvement.

I rebased onto develop and resolved the conflict (the limit logic had evolved there). I also pushed two fixes:

  1. Bug: -n 20 and --max-count=20 extractionhas_limit_flag correctly detected these forms, but the extraction block only matched the combined -20 form. Extracted a parse_user_limit() function that handles all 4 forms: -20, -n 20, --max-count=20, --max-count 20.

  2. Token savings test — Added test_filter_log_output_token_savings asserting ≥60% savings per our testing policy.

799 tests pass. Merging into develop.

@pszymkowiak pszymkowiak merged commit e06d77e into rtk-ai:develop Mar 11, 2026
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.

rtk git log --oneline silently truncates the log to 10 entries.

2 participants