GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Address review feedback about dangling commondir · gitpython-developers/GitPython@83c3e64

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • git/repo
    • fun.py
  • test
    • test_repo.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/repo/fun.py‎

Copy file name to clipboardExpand all lines: git/repo/fun.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ def is_git_dir(d: PathLike) -> bool:
8787
if common_dir == "":
8888
return False
8989
if common_dir is None:
90+
common_dir_file = Path(d) / "commondir"
9091
try:
91-
common_dir = os.fsdecode((Path(d) / "commondir").read_bytes()).rstrip("\r\n")
92+
common_dir = os.fsdecode(common_dir_file.read_bytes()).rstrip("\r\n")
9293
except FileNotFoundError:
94+
if osp.lexists(common_dir_file):
95+
return False
9396
common_dir = os.fspath(d)
9497
except OSError:
9598
return False
Collapse file

‎test/test_repo.py‎

Copy file name to clipboardExpand all lines: test/test_repo.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,17 @@ def test_repo_discovery_rejects_invalid_metadata(self):
181181
with self.subTest(metadata=".git", contents=contents):
182182
self.assertRaises(InvalidGitRepositoryError, Repo, path)
183183

184+
@requires_symlinks
185+
def test_repo_discovery_rejects_dangling_commondir(self):
186+
with tempfile.TemporaryDirectory() as tdir:
187+
path = Path(tdir)
188+
(path / "objects").mkdir()
189+
(path / "refs").mkdir()
190+
(path / "HEAD").write_text("ref: refs/heads/main\n")
191+
(path / "commondir").symlink_to("missing")
192+
193+
self.assertRaises(InvalidGitRepositoryError, Repo, path)
194+
184195
def test_repo_discovery_uses_storage_environment(self):
185196
with tempfile.TemporaryDirectory() as tdir:
186197
git_dir = Path(tdir) / "git"

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.