r/programming • • Jun 14 '20

GitHub will no longer use the term 'master' as default branch because of negative association

https://twitter.com/natfriedman/status/1271253144442253312
3.3k Upvotes

2.4k comments sorted by

View all comments

Show parent comments

6

u/[deleted] Jun 15 '20

The problem is that you can't really ask a repo what its default branch is from the web.

Uh, yeah you can. It happens as part of the initial clone every time.

12

u/Izzyanut Jun 15 '20

The problem for some scripts is that it adds a lot of complexity.

For example, with Shields mentioned above, they can figure out default GitHub branch via the API, however some badges don't use the API for what they generate, so it would result in two data requests for the badge. Changing the assumed name will break all existing ones as well, which is another issue.

Then there's other services, that integrate with that code base (For example CI/CD) that don't have a way to request the default branch. So you may not have a way to tell what name to use.

Is this going to break everything and have no work arounds? No, but it is going to break a lot of projects that use Git, or that may not be maintained anymore.

1

u/flying-sheep Jun 15 '20

Then they should change their gui so you have to enter your repo name, then it does the default branch request, and then it presents you with URLs that contain am explicitly stated branch.

Legacy URLs will default to master, new repos will have to contain badge URLs that specify the default branch name.

1

u/Izzyanut Jun 15 '20

That's one solution, and might be the way they have to go. Still a shame to loose the default branch aspect. Hopefully another solution can be found that will keep that possible.

0

u/[deleted] Jun 15 '20 edited Jun 15 '20

I really don't think so. Does Shields not work with git-flow? Because if it does, it's already doing the relevant default branch work (as the default is something like dev or develop for git-flow style repos) - and if it doesn't, that's their problem.

Also, I don't believe they're going to be renaming existing repos' default branches. That would be a crazy amount of overreach. But they have power over how the web UI initializes repos, which is an easy and non-breaking change.

Incidentally, the way to get the remote branch without cloning the repo is: git remote show {repo-url} | grep 'HEAD'

7

u/Izzyanut Jun 15 '20

Shields provides badges for your project, for example, build status, downloads, current release etc to be included in your project Readme's or website. It has a large list of sources in can call against, including a large array of CI/CD providers, Code Base Providers and many more.

It has no actual interaction with the Git aspect of your project, or codebase. It assumes your default branch is the default branch (Currently master) and if not, you need to provide the branch. So for example, if your project doesn't use master, but instead uses develop, you provide that in the badge url and it uses that instead.

Changing the default branch name, breaks that. Either new projects have to provide the branch name, or old projects break, unless we can find an elegant workaround. We also want to keep needless API requests to a minimum, for example, some badges request the raw data from Github (package,json for example) to workaround data limits in the API. To get the default branch name and then still request from raw, would mean an additional request and a performance hit. If you have 10 or more badges all affected by that in a project it really adds up. Even if they leave existing projects as-is, it is going to break this service in some ways.

It's not their problem that the default has is going to be changed, and they are looking at potential solutions. Saying it's their problem is like saying it's a car manufactures problem you changed the engine and it didn't already have a way to tell what engine was installed.

Edit: Just to address your edit, yes you can get a default branch, but that doesn't work in a Javascript based image generator that is also trying to avoid a performance hit, nor does it solve the problems with CI/CD providers also changing.

1

u/[deleted] Jun 15 '20

Default branches have been a thing for a while now. It's not GitHub's fault Shields hasn't fixed their shit.

0

u/Izzyanut Jun 15 '20

And it's not shields fault that people have taken offence at a word and are now changing how it works. This is just one example, and I'm sure there are going to be many out there. It's going to break shit, because people are upset over a word being used in a different context.

4

u/AlexAegis Jun 15 '20

read the attached issue and then you'll know.

spoiler: they do, but only because the branch is an optional parameter which defaults to master

0

u/[deleted] Jun 15 '20

[deleted]

4

u/andersk Jun 15 '20

Without cloning: git ls-remote --symref https://github.com/desktop/desktop.git HEAD.