Buggy code:
public class DefaultBuildChooser extends BuildChooser { private static final BranchSpec HEAD = new BranchSpec ( "*//HEAD" ) ; @ DataBoundConstructor public DefaultBuildChooser ( ) { } @ Override public Collection < Revision > getCandidateRevisions ( boolean isPollCall , String singleBranch , GitClient git , TaskListener listener , BuildData data , BuildChooserContext context ) throws GitException , IOException , InterruptedException { verbose ( listener , "getCandidateRevisions({0},{1},,,{2})<seq2seq4repair_space>considering<seq2seq4repair_space>branches<seq2seq4repair_space>to<seq2seq4repair_space>build" , isPollCall , singleBranch , data ) ; if ( ( singleBranch == null ) || ( singleBranch . contains ( "*" ) ) ) return getAdvancedCandidateRevisions ( isPollCall , listener , new GitUtils ( listener , git ) , data , context ) ; if ( ( ! isPollCall ) && ( singleBranch . matches ( "[0-9a-f]{6,40}" ) ) ) { try { ObjectId sha1 = git . revParse ( singleBranch ) ; Revision revision = new Revision ( sha1 ) ; revision . getBranches ( ) . add ( new Branch ( "detached" , sha1 ) ) ; verbose ( listener , "Will<seq2seq4repair_space>build<seq2seq4repair_space>the<seq2seq4repair_space>detached<seq2seq4repair_space>SHA1<seq2seq4repair_space>{0}" , sha1 ) ; return Collections . singletonList ( revision ) ; } catch ( GitException e ) { verbose ( listener , "Not<seq2seq4repair_space>a<seq2seq4repair_space>valid<seq2seq4repair_space>SHA1<seq2seq4repair_space>{0}" , singleBranch ) ; } } Collection < Revision > revisions = new ArrayList < Revision > ( ) ; if ( ! ( singleBranch . contains ( "//" ) ) ) { Set < String > tags = git . getTagNames ( singleBranch ) ; if ( ( tags . size ( ) ) != 0 ) { verbose ( listener , "{0}<seq2seq4repair_space>is<seq2seq4repair_space>a<seq2seq4repair_space>tag" ) ; return getHeadRevision ( isPollCall , singleBranch , git , listener , data ) ; } for ( RemoteConfig config : gitSCM . getRepositories ( ) ) { String repository = config . getName ( ) ; String fqbn = ( repository + "//" ) + singleBranch ; verbose ( listener , "Qualifying<seq2seq4repair_space>{0}<seq2seq4repair_space>as<seq2seq4repair_space>a<seq2seq4repair_space>branch<seq2seq4repair_space>in<seq2seq4repair_space>repository<seq2seq4repair_space>{1}<seq2seq4repair_space>-><seq2seq4repair_space>{2}" , singleBranch , repository , fqbn ) ; revisions . addAll ( getHeadRevision ( isPollCall , fqbn , git , listener , data ) ) ; } } else { List < String > possibleQualifiedBranches = new ArrayList < String > ( ) ; boolean singleBranchIsQualified = false ; for ( RemoteConfig config : gitSCM . getRepositories ( ) ) { String repository = config . getName ( ) ; <START_BUG> if ( singleBranch . startsWith ( ( repository + "//" ) ) ) { <END_BUG> singleBranchIsQualified = true ; break ; } String fqbn = ( repository + "//" ) + singleBranch ; verbose ( listener , "Qualifying<seq2seq4repair_space>{0}<seq2seq4repair_space>as<seq2seq4repair_space>a<seq2seq4repair_space>branch<seq2seq4repair_space>in<seq2seq4repair_space>repository<seq2seq4repair_space>{1}<seq2seq4repair_space>-><seq2seq4repair_space>{2}" , singleBranch , repository , fqbn ) ; possibleQualifiedBranches . add ( fqbn ) ; } if ( singleBranchIsQualified ) { revisions . addAll ( getHeadRevision ( isPollCall , singleBranch , git , listener , data ) ) ; } else { for ( String fqbn : possibleQualifiedBranches ) { revisions . addAll ( getHeadRevision ( isPollCall , fqbn , git , listener , data ) ) ; } } } return revisions ; } private Collection < Revision > getHeadRevision ( boolean isPollCall , String singleBranch , GitClient git , TaskListener listener , BuildData data ) throws InterruptedException { } private Revision objectId2Revision ( String singleBranch , ObjectId sha1 ) { } private List < Revision > getAdvancedCandidateRevisions ( boolean isPollCall , TaskListener listener , GitUtils utils , BuildData data , BuildChooserContext context ) throws GitException , IOException , InterruptedException { } private void verbose ( TaskListener listener , String format , Object ... args ) { } @ Extension public static final class DescriptorImpl extends BuildChooserDescriptor { @ Override public String getDisplayName ( ) { } @ Override public String getLegacyId ( ) { } } }

Fix:
if ( ( singleBranch . startsWith ( ( repository + "//" ) ) ) || ( singleBranch . startsWith ( ( ( "remotes//" + repository ) + "//" ) ) ) ) {