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

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

david
RBTools
release-2.0.x
rbtools

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.
Summary
Add support for Git's new defaultBranch config and support worktrees.
Description From Last Updated

Can you add :file: to the .git?

chipx86chipx86

Here, too.

chipx86chipx86

Missing period.

chipx86chipx86
chipx86
  1. Looks good! Thanks for taking this on. There's a couple tiny little doc nits, but that's it.

  2. rbtools/clients/git.py (Diff revision 1)
     
     

    Can you add :file: to the .git?

  3. rbtools/clients/git.py (Diff revision 1)
     
     

    Here, too.

  4. rbtools/clients/git.py (Diff revision 1)
     
     

    Missing period.

  5. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.0.x (2b7a120)
Loading...