From: Scott Worley Date: Fri, 9 Jul 2021 22:56:29 +0000 (-0700) Subject: Suppress git's init.defaultBranch hints X-Git-Tag: v1.4.1~2 X-Git-Url: http://git.scottworley.com/git-cache/commitdiff_plain/21971f7fbf702a0e9e35a3716b999ade7d02dd34?ds=inline Suppress git's init.defaultBranch hints --- 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: