@@ -286,8 +286,8 @@ public void deleteBranchesNotIn(Set<String> relevantBranches) throws Exception {
286286 try (Git parentgit = new Git (parentRepository )) {
287287 List <Ref > call = parentgit .branchList ().setListMode (ListMode .REMOTE ).call ();
288288 for (Ref ref : call ) {
289- if (ref .getName ().startsWith ("refs/remotes" )) {
290- String branchName = ref .getName ().substring (ref . getName (). lastIndexOf ( "/" ) + 1 );
289+ if (ref .getName ().startsWith ("refs/remotes/origin/ " )) {
290+ String branchName = ref .getName ().substring ("refs/remotes/origin/" . length () );
291291 if (!relevantBranches .contains (branchName ) && !branchName .equals (masterBranchName )) {
292292 logger .info ("Pushing deletion of branch " + ref .getName () );
293293 // delete locally
@@ -326,8 +326,8 @@ public void createMissingParentBranches(Set<String> relevantBranches)
326326 try (Git parentgit = new Git (parentRepository )) {
327327 List <Ref > call = parentgit .branchList ().setListMode (ListMode .REMOTE ).call ();
328328 for (Ref ref : call ) {
329- if (ref .getName ().startsWith ("refs/remotes" )) {
330- String branchName = ref .getName ().substring (ref . getName (). lastIndexOf ( "/" ) + 1 );
329+ if (ref .getName ().startsWith ("refs/remotes/origin/ " )) {
330+ String branchName = ref .getName ().substring ("refs/remotes/origin/" . length () );
331331 parentBranches .add (branchName );
332332 }
333333 }
@@ -392,9 +392,9 @@ public void updateAllBranchesModules() throws IOException, GitAPIException, GitS
392392 try (Git parentgit = new Git (parentRepository )) {
393393 List <Ref > call = parentgit .branchList ().setListMode (ListMode .REMOTE ).call ();
394394 for (Ref ref : call ) {
395- if (ref .getName ().startsWith ("refs/remotes" )) {
395+ if (ref .getName ().startsWith ("refs/remotes/origin/ " )) {
396396 updateBranchesForModules (parentgit ,
397- ref .getName ().substring (ref . getName (). lastIndexOf ( "/" ) + 1 ));
397+ ref .getName ().substring ("refs/remotes/origin/" . length () ));
398398 }
399399 }
400400 }
@@ -428,8 +428,8 @@ public void updateBranchesForModules(Git parentgit, String consideredBranch)
428428 Ref trackedBranchRef = null ;
429429 List <Ref > branches = submodulegit .branchList ().setListMode (ListMode .REMOTE ).call ();
430430 for (Ref ref : branches ) {
431- if (ref .getName ().startsWith ("refs/remotes" )) {
432- String branchName = ref .getName ().substring (ref . getName (). lastIndexOf ( "/" ) + 1 );
431+ if (ref .getName ().startsWith ("refs/remotes/origin/ " )) {
432+ String branchName = ref .getName ().substring ("refs/remotes/origin/" . length () );
433433 if (branchName .equals (consideredBranch )) {
434434 trackedBranchName = consideredBranch ;
435435 trackedBranchRef = ref ;
@@ -548,8 +548,8 @@ public void checkoutBranch(Git git, String branchName) throws GitAPIException, G
548548 // else look for a remote branch with this name
549549 List <Ref > call = git .branchList ().setListMode (ListMode .REMOTE ).call ();
550550 for (Ref ref : call ) {
551- if (ref .getName ().startsWith ("refs/remotes" )) {
552- String remotebranchName = ref .getName ().substring (ref . getName (). lastIndexOf ( "/" ) + 1 );
551+ if (ref .getName ().startsWith ("refs/remotes/origin/ " )) {
552+ String remotebranchName = ref .getName ().substring ("refs/remotes/origin/" . length () );
553553 if (branchName .equals (remotebranchName )) {
554554 git .checkout ()
555555 .setName (branchName )
0 commit comments