To clarify, a full fix of JENKINS-48061 requires to handle two cases:
- The case where the revision is contained in the history of at least one branch in refs/heads/*:refs/remotes/@{remote}/*
- The case where the revision is either not advertised as a head (rare and I expect we could fail for that case) or is advertised as a ref but not a ref in refs/heads (much more common, but should still be rare... in most cases a regular branch will contain the revision somewhere in its history)
Fixing the first case is a case of changing client.getBranchesContaining(hash, false) to client.getBranchesContaining(hash, true) and the follow-up of reconstructing the branch name from the local checkout's remote refs. This first case does not require this change
Fixing the second case requires this change as we need to tell GitSCMBuilder to construct a different refspec other than +refs/heads/${SCMHead.getName()}:refs/remotes/@{remote}/${SCMHead.getName()} which would blow up both for a raw revision and for a ref that is not in refs/heads in the remote repository
I am guessing this is intended to assist in a fix of
JENKINS-48061?