GetComponents assumes that default branch name is "master"

Create issue
Issue #2580 new
Roland Haas created an issue

When using a stanza like this:

!TYPE     = git
!URL      =

GetComponents fails with:

> bin/GetComponents --verbose --root . thornlists/
  Checking out module: Foo/Foo
      from repository:
                 into: ./arrangements
Executing: mkdir -p './repos'
Executing: git clone './repos/Foo'
Cloning into './repos/Foo'...
Executing: git tag -l
       In: './repos/Foo'
Executing: git checkout --track -b main origin/main
       In: './repos/Foo'
fatal: A branch named 'main' already exists.
Executing: mv './repos/Foo' './repos/Foo.branch.failed.1'

Warning: Could not checkout Foo/Foo, unable to switch to branch main. Any existing symlinks to Foo/Foo will be broken

This can be made to work by leaving out the REPO_BRANCH option altogether, which is doable but not ideal.

Comments (1)

  1. Roland Haas reporter

    Hackathon (Perl).

    A way to get the default branch name is using this code:

    default_branch=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')

  2. Log in to comment