• 
      

    Add support for Git's new defaultBranch config and support worktrees.

    Review Request #11157 — Created Sept. 2, 2020 and submitted — Latest diff uploaded

    Information

    RBTools
    release-2.0.x

    Reviewers

    While it was never difficult to use branch names other than "master" for
    the mainline development trunk in a repository, it was far and away the
    convention. As people have started to think about the language used in
    our tooling, more and more people are likely to move to "main" or some
    other name. Git has added a new config option to make this easier for
    initializing new repositories.

    RBTools would usually pick up non-default names for tracking branches
    already, since it uses git's "branch.X.remote" config keys. However,
    that doesn't work for bare repositories where there's no HEAD, and in
    the case that those config keys don't work for some reason, we still
    want a more correct fallback. This change adds that test to look up the
    configured default branch name and try that first, and then finally just
    returning "origin/master".

    While I was doing this, I also fixed up the git-dir detection when the
    current repo is a worktree created from a checkout elsewhere. This
    didn't actually impact anything since the git-dir usage that would have
    been impacted only applied to git-p4 checkouts which are highly unlikely
    to have worktrees, but it makes things more correct.

    • Ran unit tests.
    • Manually verified new git-dir detection behavior with my local
      worktree.

    Commits

    Files