Skip to content

fix(check): scope FETCH_HEAD reset to single-branch fetch path#471

Open
tripleawwy wants to merge 1 commit intoconcourse:masterfrom
netresearch:fix/scope-fetch-head-reset
Open

fix(check): scope FETCH_HEAD reset to single-branch fetch path#471
tripleawwy wants to merge 1 commit intoconcourse:masterfrom
netresearch:fix/scope-fetch-head-reset

Conversation

@tripleawwy
Copy link

Fixes #470

Problem

PR #461 (fixing #448) changed the fetch to multi-branch when tag filtering is enabled, but the existing git reset --soft FETCH_HEAD on the next line now picks up the wrong branch. With multiple branches in FETCH_HEAD, the reset takes the first entry (alphabetically sorted), which is typically not the tracked branch. This corrupts refs/heads/<branch> and causes --merged <branch> in the tag discovery to resolve to the wrong commit, silently missing tags.

Fix

Move git reset --soft FETCH_HEAD into the else (single-branch) path where it was originally designed to run (commit 1a71141). The tags-case fetch with refs/heads/*:refs/heads/* already updates refs/heads/* directly via the refspec, making the reset redundant in that path.

Reproduction

See #470 for a full reproduction script and detailed analysis.

The `git reset --soft FETCH_HEAD` was introduced in commit 1a71141 for
single-branch fetches where FETCH_HEAD has exactly one entry. PR concourse#461
changed the fetch to multi-branch when tag filtering is enabled, but
did not update the reset. With multiple branches in FETCH_HEAD, the
reset picks the first entry (alphabetically), which is typically not
the tracked branch. This corrupts refs/heads/<branch> and causes
`git tag --merged <branch>` to resolve to the wrong commit, silently
missing tags.

Move the reset into the else (single-branch) path where it is needed.
The tags-case fetch with refs/heads/*:refs/heads/* already updates
refs/heads/* directly via the refspec, making the reset redundant.

Fixes concourse#470
@tripleawwy tripleawwy requested a review from a team as a code owner March 26, 2026 12:19
@linux-foundation-easycla
Copy link

CLA Not Signed

@CybotTM
Copy link

CybotTM commented Mar 26, 2026

nothing easy in EasyCLA ...

@taylorsilva
Copy link
Member

Just read the issue. Thanks for the detailed write up @tripleawwy. I'll dig into this more and review the PR.

Do you have any issues with the EasyCLA check? Pretty sure you can make an account using GitHub as the IDP and then it'll pass.

@CybotTM
Copy link

CybotTM commented Mar 27, 2026

Hi,

and is there no way that a simple --signoff / -s satisfies your requirements?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

git reset --soft FETCH_HEAD after multi-branch fetch corrupts refs/heads when tag filtering is enabled

3 participants