@@ -405,6 +405,9 @@ rediscover_default_branch <- function(old_name = NULL, report_on_source = TRUE)
405405  #  git branch -u origin/NEW-BRANCH-NAME NEW-BRANCH-NAME
406406  #  git remote set-head origin -a
407407
408+   #  optionally
409+   #  git remote prune origin
410+ 
408411  #  Note: they are assuming the relevant repo is known as origin, but it could
409412  #  just as easily be, e.g., upstream.
410413
@@ -427,7 +430,6 @@ rediscover_default_branch <- function(old_name = NULL, report_on_source = TRUE)
427430  #  for very stale repos, a fetch is a necessary pre-requisite
428431  #  I provide `refspec = db` to avoid fetching all refs, which can be VERY slow
429432  #  for a repo like ggplot2 (several minutes, with no progress reporting)
430-   #  however this means I can't do `prune = TRUE` to prune, e.g. origin/master
431433  gert :: git_fetch(remote  =  tr $ name , refspec  =  db , verbose  =  FALSE , repo  =  repo )
432434  gert :: git_remote_ls(remote  =  tr $ name , verbose  =  FALSE , repo  =  repo )
433435
@@ -447,6 +449,16 @@ rediscover_default_branch <- function(old_name = NULL, report_on_source = TRUE)
447449    repo  =  repo 
448450  )
449451
452+   #  goal: get rid of old remote tracking branch, e.g. origin/master
453+   #  goal, in Git-speak: git remote prune origin
454+   #  I provide a refspec to avoid fetching all refs, which can be VERY slow
455+   #  for a repo like ggplot2 (several minutes, with no progress reporting)
456+   gert :: git_fetch(
457+     remote  =  tr $ name ,
458+     refspec  =  glue(" refs/heads/{old_name}:refs/remotes/{tr$name}/{old_name}"  ),
459+     verbose  =  FALSE , repo  =  repo , prune  =  TRUE 
460+   )
461+ 
450462  #  for "ours" and "theirs", the source repo is the only remote on our radar and
451463  #  we're done ingesting the default branch from the source repo
452464  #  but for "fork", we also need to update
@@ -461,9 +473,13 @@ rediscover_default_branch <- function(old_name = NULL, report_on_source = TRUE)
461473        from  =  old_name_fork ,
462474        new_name  =  db 
463475      )
464-       #  giving refspec has same pros and cons as noted above for source repo
465476      gert :: git_fetch(remote  =  " origin"  , refspec  =  db , verbose  =  FALSE , repo  =  repo )
466477      gert :: git_remote_ls(remote  =  " origin"  , verbose  =  FALSE , repo  =  repo )
478+       gert :: git_fetch(
479+         remote  =  " origin"  ,
480+         refspec  =  glue(" refs/heads/{old_name}:refs/remotes/origin/{old_name}"  ),
481+         verbose  =  FALSE , repo  =  repo , prune  =  TRUE 
482+       )
467483    }
468484  }
469485
0 commit comments