-
Notifications
You must be signed in to change notification settings - Fork 101
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
Browsing to a repo shows the most recently updated branch, rather than the default #307
Comments
Ah, I see Klaus tries to get the default branch: Line 141 in 3cbab50
But the version I'm running (1.5.2-4) doesn't include 'main' in that list, and at least one of my repos doesn't have a standard default branch name. Ideally "HEAD" should be used, but I haven't investigated if that's easy to reference using dulwich. |
HEAD gives the currently checked out branch, not the default branch |
For a bare repo, which I assume is the main use case for a web-based repo viewer like Klaus, these are equivalent. How else would one deal with the scenario where the default branch (e.g. "stable") is neither in the shortlist of repo names, nor the most recently updated branch? |
Maybe something similar to this? https://github.blog/2020-07-27-highlights-from-git-2-28/#introducing-init-defaultbranch |
I think if you just browse to https://git.example.com/foo you should see the same branch by default as if you did https://git-scm.com/docs/git-clone#Documentation/git-clone.txt--bltnamegt says
i.e. if you don't say |
Good point, someone needs to think through what this means for
As an example for a non bare repo I don’t expect HEAD to be what is cloned and shown by default, but the default branch (whatever way we define that) |
Insofar as the repo list, I don't see why this would introduce any changes at all. Likewise, for Smart HTTP cloning, the behaviour I expect is what would align with cloning over git or ssh protocols: the client should check out the HEAD branch unless explicitly instructed otherwise. If that's not already the case, I consider it a bug. For the Web UI, what I think should happen is that in most cases when browsing to a repo, browsing to
Why don't you expect that? As per
The behaviour I'm proposing exactly aligns with this documentation. |
Hmm that’s a good point although I think it can be surprising if you have accidentally checked out eg a feature branch. |
The change I'm proposing doesn't change the behaviour of a check-out at all. Check-out doesn't care what branch Klaus displays in the web UI. It will checkout HEAD unless told otherwise, regardless of the change proposed in #308. |
Or are you referring to what is checked out on the server-side copy of the repo that Klaus is looking at? |
Wow, I didn't know that's already the case! Thanks for pointing that out. I think that will simplify things a lot. |
I like the simplicity of this but I'm not sure it is desirable in all cases. If you have a local repo that you are actively working on and viewing in Klaus, it might be confusing that the "repo start page" will change its contents depending on what's the current HEAD. GitHub doesn't have this problem because they will always have HEAD pointed to the default branch. |
Hrm, I didn't realize klaus even worked with non-bare repos! |
If you'd like to investigate that'd be appreciated :) |
This is already confusing, because with the current behaviour, if I don't use the "standard" branch names of "main", "master", "trunk", etc., every time somebody makes a new commit to one of the repo's branches, the branch I'm looking at on the start page changes. This is why I filed this bug in the first place. How about adding a feature flag that can be turned on so one can opt in to the behaviour I'm suggesting, with the default being to do nothing different than is currently happening (at least for the time being; maybe a flag-day in the future can change the default with sufficient notice)? |
You are right, that really makes little sense. Fixed in #312. |
For bare repos we might want to go further and always show HEAD on the repo page. For non-bare repos, I'm not so sure. |
When I browse to a repo in Klaus whose default branch (as defined in
repo.git/HEAD
), if I have made a commit to a different branch (e.g. "foo") more recently than the most recent commit on HEAD, it will show me branchfoo
instead, which is unexpected and, in my opinion, undesirable.The text was updated successfully, but these errors were encountered: