fix(git): run_log silently injects --no-merges, hiding merge commits

Open Beginner friendly
#1,853 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
git, rust
Domain
cli

Research direction

Start in run_log() around lines 492-498, where the git log command is assembled and --no-merges is added. Reproduce the merge history from the issue, then verify that rtk git log preserves merge commits and graph topology while an explicit --no-merges argument still works.

Written by the indexing model from the issue text.

Description

area:cli bug priority:high

🤖 This was written by an AI agent on behalf of @paolomainardi.

Description

run_log() unconditionally adds --no-merges to all git log commands unless the user explicitly passes --merges. This silently removes all merge commits from the output with no indication they were filtered.

For AI agents, this is a correctness bug: the agent cannot see that branches were merged, leading to wrong conclusions about branch topology and project history.

Root Cause

Lines ~492-498 in run_log():

// Only add --no-merges if user didn't explicitly request merge commits
let wants_merges = args
    .iter()
    .any(|arg| arg == "--merges" || arg == "--min-parents=2");
if !wants_merges {
    cmd.arg("--no-merges");
}

Reproduction

# Create a repo with a merge commit
git init test-repo && cd test-repo
echo "a" > a.txt && git add . && git commit -m "initial"
git checkout -b feature
echo "b" > b.txt && git add . && git commit -m "feature work"
git checkout master
git merge --no-ff feature -m "Merge branch 'feature'"
echo "c" > c.txt && git add . && git commit -m "after merge"

# Raw: 4 commits (including merge)
git log --oneline | wc -l
# Output: 4

# RTK: 3 commits (merge silently removed)
rtk git log --oneline | wc -l
# Output: 3

# The merge commit is completely invisible
rtk git log --oneline | grep "Merge"
# Output: (empty)

Side Effects

  • git log --graph shows corrupted topology because the merge node is removed and the graph is redrawn incorrectly
  • Agents that check "was this branch merged?" get the wrong answer
  • git log --oneline count disagrees with git rev-list --count

Fix

Remove the --no-merges injection entirely. If users want to filter merge commits, they can pass --no-merges explicitly. RTK should not silently alter the semantics of git commands.

Impact

  • Severity: High — merge commits vanish completely, corrupts history understanding
  • Token cost: +1 line per merge commit in history — negligible
  • Version: Verified on v0.39.0

Related

  • #619 (git log issues)
  • #1704 (git log filtering)
Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 11h
Merged PRs (30d)
42

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rtk-ai/rtk

All issues in rtk-ai/rtk

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.