Deleting old upstream branches

115 views
Skip to first unread message

Erik Bray

unread,
Jun 27, 2018, 6:53:30 AM6/27/18
to sage-devel
Hi everyone,

The list of branches that have been pushed to git.sagemath.org is
extremely long. At my latest count there are 23979 branches on there
(congratulations on everyone's hard work!).

However, leaving up so many old branches is not entirely without
impact. While merged branches don't ultimately contribute much to the
size of the repository (as all the commits in those branches are
merged into the mainline (master, develop) branches) it still impacts
that efficiency of some of the tooling, especially anything that
involves listing branches.

For example, in the https://git.sagemath.org/ web interface, at the
top of the page is a drop-down list from which one can select a branch
to view, and that list contains all 20,000+ of those branches, which
actually noticeably slows down page loads on some machines.

I would suggest, as often as possible, deleting your branches from
upstream once they've been merged (I myself have been lax about this).
Nothing is lost if you do this for merged branches, because when a
branch attached to a ticket is merged and the ticket closed, the
branch name is actually replaced with the merge commit SHA on the
ticket, so you can still view exactly what was merged for a given
ticket.

Here's a little command line snippet I came up with to delete all my
upstream merged branches (if someone knows a better way please chime
in--I just came up with this without consulting any resources):

$ UPSTREAM="upstream"
$ USERNAME="embray"
$ git branch -r --merged | grep "$UPSTREAM/u/$USERNAME" | sed
's|'$UPSTREAM'/|:|' | xargs git push $UPSTREAM

here just replace "upstream" with whatever your upstream remote is
called for git.sagemath.org (it's more typically "origin") and
"embray" with your trac username. This just takes the names of all
merged remote branches from $UPSTREAM, strips the $UPSTREAM and
prepends them with ":", and then passes those to "git push". The
syntax "git push <remote> :<branch-name>" means to delete the given
branch from the given remote.

I did this just for myself and deleted ~205 branches. Perhaps
functionality like this could also be added to the git-trac command?

Thanks,
E

Frédéric Chapoton

unread,
Jun 27, 2018, 1:05:25 PM6/27/18
to sage-devel
I just did that for myself, as suggested. One branch refuses to disappear: u/chapoton/22230 which apparently both exists and does not exist..

Should we also do that for the merged "public/*" branches ?

Frédéric

Erik Bray

unread,
Jun 27, 2018, 1:15:18 PM6/27/18
to sage-devel
On Wed, Jun 27, 2018 at 7:05 PM Frédéric Chapoton <fchap...@gmail.com> wrote:
>
> I just did that for myself, as suggested. One branch refuses to disappear: u/chapoton/22230 which apparently both exists and does not exist..

No idea...

> Should we also do that for the merged "public/*" branches ?

Personally I'm hesitant to touch that just because I don't want to go
deleting *anyone*'s branches that aren't my own. However, personally,
I believe there is no harm, especially since:

$ git br -r | grep 'upstream/public/' | wc -l
2034

So maybe vote on it? I'm +1.
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To post to this group, send email to sage-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.

Volker Braun

unread,
Jun 27, 2018, 2:11:47 PM6/27/18
to sage-devel
I'm fine with auto-deleting merged branches, but IMHO thats just doctoring around the symptoms. Listing all branches is just a fundamentally useless view of the repo, akin to listing all your files alphabetically. Even if we auto-delete merged branches there will always be crud because some branches are just intentionally abandoned. We can make the list of branches smaller, but that doesn't change the fact that the signal-to-noise ratio tends to 0 as time increases.

In cgit you can set enable-remote-branches=0, though I'm not sure if thats the right option to fix the drop-down.

Marc Mezzarobba

unread,
Jun 28, 2018, 5:27:55 AM6/28/18
to sage-...@googlegroups.com
Erik Bray wrote:
> Personally I'm hesitant to touch that just because I don't want to go
> deleting *anyone*'s branches that aren't my own.

FWIW, I've been deleting my old branches as well as some old public
branches I had worked on for years now, and I don't think anyone ever
complained.

--
Marc

Travis Scrimshaw

unread,
Jun 28, 2018, 6:59:31 AM6/28/18
to sage-devel
Should we also do this automatically for public/* branches? Or at least every stable/beta release?

Best,
Travis

Ralf Stephan

unread,
Jun 28, 2018, 10:26:17 AM6/28/18
to sage-devel
On Wednesday, June 27, 2018 at 12:53:30 PM UTC+2, Erik Bray wrote:
I did this just for myself and deleted ~205 branches.

~127 here.

Erik Bray

unread,
Jun 28, 2018, 10:39:25 AM6/28/18
to sage-devel
On Wed, Jun 27, 2018 at 8:11 PM Volker Braun <vbrau...@gmail.com> wrote:
>
> I'm fine with auto-deleting merged branches, but IMHO thats just doctoring around the symptoms. Listing all branches is just a fundamentally useless view of the repo, akin to listing all your files alphabetically. Even if we auto-delete merged branches there will always be crud because some branches are just intentionally abandoned. We can make the list of branches smaller, but that doesn't change the fact that the signal-to-noise ratio tends to 0 as time increases.

I disagree that it's a "fundamentally useless view of the repo".
Sometimes I'm looking for a specific branch and don't know the exact
name, but know I would recognize it when I see it. Sometimes this is
a problem even with my own branches which is why I try to regularly
clean up ones I don't need anymore.

Even if listing all branches in the repository were useless (it isn't)
it's certainly useful to clean up one's own branches, so this is a
good pointer for people to have (and perhaps useful to have in `git
trac`).


> In cgit you can set enable-remote-branches=0, though I'm not sure if thats the right option to fix the drop-down.

It's not.
Reply all
Reply to author
Forward
0 new messages