From b3adcb18ef762d8652272e2ea68c0f416f33c740 Mon Sep 17 00:00:00 2001 From: okwn Date: Thu, 21 May 2026 10:16:09 +0000 Subject: [PATCH 1/2] fix: honor explicit -n N limit for git log on merge commits When user runs 'git log -1 --format='%H' HEAD' where HEAD is a merge commit, rtk was adding --no-merges which filtered out the merge commit itself and returned the second parent instead. This made 'git log -1' return wrong SHAs for merge commits. Fix: don't add --no-merges when user explicitly passes -n N or --max-count=N. When a user specifies an exact count they expect exactly that many commits, not filtered results. Also skip --no-merges if user already passed --merges or --no-merges explicitly. Fixes rtk-ai/rtk#2009. --- src/cmds/git/git.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmds/git/git.rs b/src/cmds/git/git.rs index 6f42d20e8..95bba3729 100644 --- a/src/cmds/git/git.rs +++ b/src/cmds/git/git.rs @@ -522,8 +522,10 @@ fn 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 { + .any(|arg| arg == "--merges" || arg == "--min-parents=2" || arg == "--no-merges"); + // Don't add --no-merges if user explicitly requested merges or an exact count (-n N / --max-count) + // When user passes -1 they want 1 commit regardless of whether it's a merge + if !wants_merges && !has_limit_flag { cmd.arg("--no-merges"); } From f431fb9521b720aa58bc856b432df73cee35d735 Mon Sep 17 00:00:00 2001 From: aesoft <43991222+aeppling@users.noreply.github.com> Date: Fri, 22 May 2026 15:30:14 +0200 Subject: [PATCH 2/2] Update git.rs --- src/cmds/git/git.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cmds/git/git.rs b/src/cmds/git/git.rs index 95bba3729..5140244e6 100644 --- a/src/cmds/git/git.rs +++ b/src/cmds/git/git.rs @@ -524,7 +524,6 @@ fn run_log( .iter() .any(|arg| arg == "--merges" || arg == "--min-parents=2" || arg == "--no-merges"); // Don't add --no-merges if user explicitly requested merges or an exact count (-n N / --max-count) - // When user passes -1 they want 1 commit regardless of whether it's a merge if !wants_merges && !has_limit_flag { cmd.arg("--no-merges"); }