]> git.scottworley.com Git - git-cache/commitdiff
Suppress git's init.defaultBranch hints
authorScott Worley <scottworley@scottworley.com>
Fri, 9 Jul 2021 22:56:29 +0000 (15:56 -0700)
committerScott Worley <scottworley@scottworley.com>
Fri, 9 Jul 2021 22:59:04 +0000 (15:59 -0700)
Changelog
git_cache.py
test_git_cache.py

index e21bfc16f680a19b47b195228aea59a8a837a4e4..ca29a36ee396f8bd92f7015a7c6f23c922388cc7 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,6 @@
 ## [Unreleased]
+### Changed
+- Suppress git's init.defaultBranch hints
 
 
 ## [1.4.0] - 2021-06-21
index d54041be67fe1d3336cce7f1e03cf272288695ee..1ed26017ceb18f0831d8b5566068c6eb11fdcf7a 100644 (file)
@@ -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)
index 2990f56d50d35cbea956da36237c9967003e3199..7cd232d7d8be6c4893b1812c71945ff7f4effe22 100644 (file)
@@ -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: