Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Default branch symref

In that case HEAD points to a commit that is the tip of only one branch, if main and master had the same tip I believe you'd checkout master.

Admittedly, it's an edge-case and may not matter depending on your workflow (if you branch after cloning you'll end up in the same place), but it's an inconsistency with c git which would, I believe, use the symref to choose amongst multiple branches whose tips are the same as the advertised HEAD.

As I understand it, in the advertised refs, HEAD -> cda23c9 (i.e. the commit id, not specifically main). CloneCommand#findBranchToCheckout first checks if refs/heads/master points to the same commit as the advertised HEAD, if it does then you'll checkout master, if not you'll checkout the first branch (from an unordered Collection) that does point to the same commit as the advertised HEAD.

On Wed, 30 Sep 2020 at 22:39, Matthias Sohn <matthias.sohn@xxxxxxxxx> wrote:
On Wed, Sep 30, 2020 at 8:35 AM Lee Worrall <worrall.la@xxxxxxxxx> wrote:
With github on the verge of changing its default initial branch name from master to main, I was looking at jgit support for symrefs in pack connections.

It looks to me like a HEAD symref is included in the capability line in UploadPack but it is not parsed in BasePackConnection.

I have a small patch that adds any SymRefs into the advertisedRefs and uses any HEAD symref in CloneCommand before looking for a branch called master. Is there any interest in adding this?

I tried to clone a repository which has HEAD set to branch main using the
jgit command line client (current master) and that checked out the main branch after cloning:

$ jgit clone "http://localhost:8080/test"
Cloning into 'test'...
remote: Counting objects: 1
remote: Finding sources: 100% (13/13)
Receiving objects:      100% (13/13)
Checking out files:     100% (3/3)

$ cd test
$ git log --oneline --graph
* cda23c9 (HEAD -> main, origin/main) test
* 1ddfebc (origin/master) b
* 80f45ce a
* f2894c2 Initial empty repository

-Matthias

Back to the top