From 21971f7fbf702a0e9e35a3716b999ade7d02dd34 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 9 Jul 2021 15:56:29 -0700 Subject: [PATCH 1/1] Suppress git's init.defaultBranch hints --- Changelog | 2 ++ git_cache.py | 10 ++++++++-- test_git_cache.py | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index e21bfc1..ca29a36 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ ## [Unreleased] +### Changed +- Suppress git's init.defaultBranch hints ## [1.4.0] - 2021-06-21 diff --git a/git_cache.py b/git_cache.py index d54041b..1ed2601 100644 --- a/git_cache.py +++ b/git_cache.py @@ -176,8 +176,14 @@ def fetch(repo: Repo, ref: Ref, force: bool = False) -> Tuple[Path, Rev]: cachedir = git_cachedir(repo) if not os.path.exists(cachedir): logging.debug("Initializing git repo") - subprocess.run(['git', 'init', '--bare', cachedir], - check=True, stdout=sys.stderr) + subprocess.run(['git', + '-c', + 'init.defaultBranch=git-cache--no-default-branch', + 'init', + '--bare', + cachedir], + check=True, + stdout=sys.stderr) logging.debug('Fetching ref "%s" from %s', ref, repo) _git_fetch(cachedir, repo, ref, force=force) diff --git a/test_git_cache.py b/test_git_cache.py index 2990f56..7cd232d 100644 --- a/test_git_cache.py +++ b/test_git_cache.py @@ -56,7 +56,8 @@ class TestGitCache(unittest.TestCase): self.tempdir = tempfile.TemporaryDirectory(prefix='git_cache_test-') self.upstream = os.path.join(self.tempdir.name, 'upstream') - subprocess.run(['git', 'init', self.upstream], check=True) + subprocess.run(['git', '-c', 'init.defaultBranch=master', + 'init', self.upstream], check=True) _commit_file(self.upstream, 'file', 'Contents', 'First commit') def tearDown(self) -> None: -- 2.44.1