bisect-kit: handle git default branch name
system git may set default branch name other than 'master'. However,
chrome and chromeos haven't switched over. We need to support mixed
usage during the transition time.
BUG=b:170931629, b:168895763
TEST=./bisect_cr_localbuild_internal.py init --old 87.0.4280.0 --new 88.0.4284.0
Change-Id: Ie55200a73aa7c2257058435eee93a33e0e9452f9
diff --git a/bisect_kit/git_util.py b/bisect_kit/git_util.py
index e700e6b..f621bde 100644
--- a/bisect_kit/git_util.py
+++ b/bisect_kit/git_util.py
@@ -86,7 +86,7 @@
util.check_call('git', 'checkout', '-q', '-f', rev, cwd=git_repo)
-def init(git_repo):
+def init(git_repo, initial_branch='main'):
"""git init.
git_repo and its parent directories will be created if they don't exist.
@@ -97,7 +97,8 @@
if not os.path.exists(git_repo):
os.makedirs(git_repo)
- util.check_call('git', 'init', '-q', cwd=git_repo)
+ util.check_call(
+ 'git', 'init', '-q', '--initial-branch', initial_branch, cwd=git_repo)
def commit_file(git_repo,