Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repos without master branch fail to display. #42

Closed
dmitshur opened this issue May 7, 2016 · 4 comments
Closed

Repos without master branch fail to display. #42

dmitshur opened this issue May 7, 2016 · 4 comments

Comments

@dmitshur
Copy link
Member

dmitshur commented May 7, 2016

This is a bug that should be fixed.

E.g., currently happening with:

https://gotools.org/github.com/kr/text

image

This is related to golang/go#9032 and golang/gddo#405.

@dmitshur
Copy link
Member Author

dmitshur commented May 8, 2016

I've resolved this in ae7ecb7, which builds on work done in shurcooL/vcsstate@c4807b9.

Unfortunately, in order to reliably support branches other than "master" as default branches, an additional network call must be made.

image

/cc @kr

@kr
Copy link

kr commented May 8, 2016

That's too bad it needs an extra network call. Note that if you clone a git repo, the default branch is available as remotes/origin/HEAD. Maybe that would help?

$ git clone https://github.com/kr/text
...
$ cd text/
$ git branch -va
* main                7cafcd8 cmd/agg: new command
  remotes/origin/HEAD -> origin/main
  remotes/origin/cb   0a50dc0 add test from #4
  remotes/origin/main 7cafcd8 cmd/agg: new command
  remotes/origin/wip  67253a9 wip

@kr
Copy link

kr commented May 8, 2016

Also, thanks! This is great. :)

@dmitshur
Copy link
Member Author

dmitshur commented May 9, 2016

That's too bad it needs an extra network call. Note that if you clone a git repo, the default branch is available as remotes/origin/HEAD. Maybe that would help?

Thanks. I am aware of that, and I tried to use that initially. You can see some of those left-over experiments here.

However, I cannot rely on that for a few reasons:

  1. It's not guaranteed to be up to date. So a network call must be made in a general case. For example, imagine a worst case where the upstream repository changes its default branch from master to another-branch, and a minute later someone tries to view that repo. Unless you make a network call to query the latest current default branch, you may end up having stale, inaccurate default branch information.

  2. The symbolic ref to remotes/origin/HEAD may or may not exist. It depends on how the repo was cloned, what version of git was used, and some other factors. Also, users can do git remote set-head origin -d which will remove that symbolic ref. You can try to restore it with git remote set-head origin --auto, but that has gotchas:

    With -a or --auto, the remote is queried to determine its HEAD, then the symbolic-ref refs/remotes/<name>/HEAD is set to the same branch. e.g., if the remote HEAD is pointed at next, "git remote set-head origin -a" will set the symbolic-ref refs/remotes/origin/HEAD to refs/remotes/origin/next. This will only work if refs/remotes/origin/next already exists; if not it must be fetched first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants