fix: separate fallback push branch from pathspecs#1396
Merged
mrexox merged 1 commit intoevilmartians:masterfrom Apr 20, 2026
Merged
fix: separate fallback push branch from pathspecs#1396mrexox merged 1 commit intoevilmartians:masterfrom
mrexox merged 1 commit intoevilmartians:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a Git argument ambiguity in Repository.PushFiles() when falling back from @{push} to a default branch name that also exists as a path in the worktree, by separating revisions from pathspecs using -- and adding a regression test for that scenario.
Changes:
- Update the fallback
git diff --name-only HEAD <branch>invocation togit diff --name-only HEAD <branch> --to disambiguate branch vs. path names. - Add a regression test covering the branch/path collision case (e.g., default branch
devand adev/directory present).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
internal/git/repository.go |
Appends -- to the fallback git diff command to prevent branch/path ambiguity errors. |
internal/git/repository_test.go |
Adds a test ensuring the fallback diff uses -- and succeeds when a directory matches the branch name. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mrexox
approved these changes
Apr 20, 2026
Member
|
Thank you for preparing the PR! I'll fix linter issues |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1395
Context
When
@{push}is unavailable,PushFiles()falls back togit diff --name-only HEAD <default-branch>.If the repository also contains a directory with the same name as that default branch, Git treats the branch name as ambiguous and the pre-push hook fails before it can resolve
{push_files}.Changes
git diffrevision list with--Validation
go test ./internal/git -run TestPushFiles -count=1go test ./internal/git -count=1go test ./internal/run/controller/... -count=1go test ./... -count=1origin/HEADpoints todevand the worktree containsdev/