microsoft / scalar

Scalar: A set of tools and extensions for Git to allow very large monorepos to run on Git without a virtualization layer
MIT License
1.39k stars 63 forks source link

`scalar clone` fails if default branch is changed #438

Closed derrickstolee closed 4 years ago

derrickstolee commented 4 years ago

If we use scalar clone <url> for a repository that does not include a master branch, then we get this error:

Error: Failed to complete regular clone: error: pathspec 'master' did not match any file(s) known to git

We should respect the default branch name discovered during clone.

(This affects the non-GVFS Protocol case as well.)

cc: @dscho for advice for the proper way to detect the default branch name after a clone.

dscho commented 4 years ago

the proper way to detect the default branch name after a clone.

I think it is symbolic-ref:

$ git -c init.defaultBranch=monkey init money
Initialized empty Git repository in C:/git-sdk-64/tmp/money/.git/

$ git -C money symbolic-ref HEAD
refs/heads/monkey
dscho commented 4 years ago

FTR there is also usually a refs/remotes/origin/HEAD that is also a symbolic ref, pointing to the remote ref reflecting the default branch.