Skip to content

Name HEAD when ExcludingRemoteTrackingRefs has no revision [patch] - #211

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/161-exclude-remote-head
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/161-exclude-remote-head

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #161

What changed

git only falls back to HEAD when no revision input was given at all, and --remotes counts as input even when it is negated. So the bare Log().ExcludingRemoteTrackingRefs() ran git log --not --remotes --not and listed nothing, which reads as "nothing unpushed".

GitLogBuilder now appends HEAD through AppendOperands (after --end-of-options, outside the closed negation) when ExcludingRemoteTrackingRefs() is set and neither ForRevision nor IncludingAllRefs() was called. The interface remarks now describe this default.

Tests

  • Argv: DefaultsTheUnpushedQueryToHead checks that HEAD is the last operand and comes after the closing --not. AddsNoHeadWhenAllRefsAreIncluded checks the --all form is unchanged.
  • Integration: ReportsUnpushedCommitsFromHeadWithoutARevisionAsync uses a remote that is behind HEAD and expects exactly the one unpushed commit. ReportsEveryCommitAsUnpushedWithoutAnyRemoteAsync uses a repository with no remote and expects every commit.
  • To show the tests depend on the fix, I swapped the HEAD append for a no-op. All three behavioural tests failed, then passed again once the change was restored.
  • Full suite on Linux with git 2.43 and KTSU_GIT_INTEGRATION_TESTS_REQUIRED=1: 804 of 804 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BkmjSwCY4KW87X2ccQhj7T


Generated by Claude Code

git falls back to HEAD only when no revision input was given, and
--remotes counts as input even when negated, so the bare
Log().ExcludingRemoteTrackingRefs() ran "git log --not --remotes --not"
and listed nothing, which reads as "nothing unpushed". The builder now
appends HEAD when neither ForRevision nor IncludingAllRefs was called.

Fixes #161

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BkmjSwCY4KW87X2ccQhj7T
@sonarqubecloud

Copy link
Copy Markdown

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.

Log().ExcludingRemoteTrackingRefs() without ForRevision returns no commits, even when HEAD has unpushed work

2 participants