| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Updates repository discovery to prioritize .git metadata, validate linked repositories, preserve common-directory handling, and document the security advisory.
Changes:
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Review summary |
|---|---|
| test/test_repo.py | Adds repository discovery and common-directory tests. |
| git/repo/fun.py | Three unresolved moderate findings: malformed HEAD targets are accepted (3 votes); malformed commondir handling can escape or raise incorrectly (2 votes); FIFO HEAD files can block discovery (2 votes). |
| git/repo/base.py | One unresolved moderate finding (2 votes): relative GIT_COMMON_DIR values can cause subsequent Git operations to target the wrong repository. |
| doc/source/changes.rst | Adds the security advisory to the changelog. |
git/repo/base.py:310
if osp.exists(dotgit) and not osp.isdir(dotgit):
break
git/repo/fun.py:97
object_dir = os.getenv("GIT_OBJECT_DIRECTORY") or osp.join(common_dir, "objects")
git/repo/fun.py:103
and osp.isfile(osp.join(d, "gitfile"))
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
|
Codex on behalf of Byron: I also checked the three suppressed review notes. Commit 32baeab now rejects empty GIT_OBJECT_DIRECTORY and restores HEAD-based linked-worktree detection. I left dangling .git symlink behavior unchanged: Git setup.c read_gitfile_gently uses stat, so a dangling symlink is treated as missing and discovery falls through to the bare candidate or parent; local git rev-parse checks confirmed that behavior. |
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Suppressed comments (6)Previously missed (2) — in code that hasn't changed since the last review.
git/repo/base.py:309
if osp.exists(dotgit) and not osp.isdir(dotgit):
git/repo/base.py:300
sm_gitpath = find_submodule_git_dir(dotgit)
git/repo/base.py:385
if common_dir_env is not None:
self.git.update_environment(GIT_DIR=os.fspath(self.git_dir), GIT_COMMON_DIR=os.fspath(self.common_dir))
git/repo/base.py:300
sm_gitpath = find_submodule_git_dir(dotgit)
git/repo/base.py:364
common_dir = (Path(self.git_dir) / "commondir").read_text().splitlines()[0].strip()
git/repo/fun.py:93
except FileNotFoundError:
common_dir = os.fspath(d)
Sorry, something went wrong.
|
Codex on behalf of Byron: I reviewed all six suppressed notes from the latest Copilot pass. Commit b8c000e fixes one-level, regular, size-bounded Gitfile resolution, filesystem decoding for .git and commondir metadata, and relative GIT_DIR persistence. Commit 83c3e64 fixes dangling commondir symlinks. I left dangling .git symlinks unchanged because Git read_gitfile_gently() uses stat and treats them as missing; the visible FIFO commondir thread likewise documents Git's file_exists()/strbuf_read_file() behavior. |
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Suppressed comments (1)Previously missed (1) — in code that hasn't changed since the last review.
git/repo/base.py:310
if osp.exists(dotgit) and not osp.isdir(dotgit):
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (3)git/repo/base.py:310
if osp.exists(dotgit) and not osp.isdir(dotgit):
git/repo/fun.py:130
try:
content = os.fsdecode(Path(dotgit).read_bytes()).rstrip("\r\n")
except OSError:
return None
return content[8:] if len(content) >= 9 and content.startswith("gitdir: ") else None
git/repo/fun.py:110
object_dir = os.getenv("GIT_OBJECT_DIRECTORY")
if object_dir is None:
object_dir = osp.join(common_dir, "objects")
if valid_head and osp.isdir(object_dir) and osp.isdir(osp.join(common_dir, "refs")):
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (5)Previously missed (2) — in code that hasn't changed since the last review.
git/repo/base.py:388
if common_dir_env is not None:
self.git.update_environment(GIT_DIR=os.fspath(self.git_dir), GIT_COMMON_DIR=os.fspath(self.common_dir))
elif git_dir_env is not None:
self.git.update_environment(GIT_DIR=os.fspath(self.git_dir))
git/repo/base.py:310
if osp.exists(dotgit) and not osp.isdir(dotgit):
git/repo/fun.py:110
object_dir = os.getenv("GIT_OBJECT_DIRECTORY")
if object_dir is None:
object_dir = osp.join(common_dir, "objects")
if valid_head and osp.isdir(object_dir) and osp.isdir(osp.join(common_dir, "refs")):
git/repo/fun.py:129
try:
content = os.fsdecode(Path(dotgit).read_bytes()).rstrip("\r\n")
except (OSError, UnicodeError):
return None
test/test_repo.py:139
Repo.init(path).close()
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Suppressed comments (8)git/repo/base.py:391
if common_dir_env is not None:
self.git.update_environment(GIT_DIR=os.fspath(self.git_dir), GIT_COMMON_DIR=os.fspath(self.common_dir))
elif git_dir_env is not None:
self.git.update_environment(GIT_DIR=os.fspath(self.git_dir))
git/repo/base.py:314
if osp.exists(dotgit) and not osp.isdir(dotgit):
break
git/repo/base.py:307
git_dir = osp.normpath(osp.join(curpath, os.fspath(sm_gitpath)))
git/repo/base.py:369
try:
common_dir = os.fsdecode((Path(self.git_dir) / "commondir").read_bytes()).rstrip("\r\n")
self._common_dir = osp.join(self.git_dir, common_dir)
git/repo/fun.py:130
content = os.fsdecode(Path(dotgit).read_bytes()).rstrip("\r\n")
except (OSError, UnicodeError):
return None
return content[8:] if len(content) >= 9 and content.startswith("gitdir: ") else None
git/repo/fun.py:93
common_dir_file = Path(d) / "commondir"
try:
common_dir = os.fsdecode(common_dir_file.read_bytes()).rstrip("\r\n")
except FileNotFoundError:
test/test_repo.py:252
assert repo.git.cat_file("blob", blob_hexsha) == payload.decode()
test/test_repo.py:223
assert osp.samefile(repo.git.rev_parse("--absolute-git-dir"), git_dir)
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Suppressed comments (3)git/repo/base.py:396
rootpath = object_dir_env if object_dir_env is not None else osp.join(self.common_dir, "objects")
git/repo/base.py:313
if osp.exists(dotgit) and not osp.isdir(dotgit):
git/repo/base.py:391
if common_dir_env is not None:
self.git.update_environment(GIT_DIR=os.fspath(self.git_dir), GIT_COMMON_DIR=os.fspath(self.common_dir))
elif git_dir_env is not None:
self.git.update_environment(GIT_DIR=os.fspath(self.git_dir))
Sorry, something went wrong.
There was a problem hiding this comment.
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (3)git/repo/base.py:313
self._working_tree_dir = curpath
git/repo/base.py:391
self._working_tree_dir = None
# END working dir handling
self.working_dir: PathLike = self._working_tree_dir or self.common_dir
git/repo/fun.py:127
with open(dotgit, "rb") as fp:
Sorry, something went wrong.
<!-- agent --> GitPython considered worktree administration and bare-repository signatures before a worktree's real .git entry. Align discovery with Git so .git files and directories win, malformed .git files stop discovery, and candidate git directories validate HEAD plus commondir-backed object and ref storage. This addresses GHSA-239g-whfq-7xj9. Regression coverage compares ambiguous layouts with git rev-parse and rejects invalid HEAD/.git metadata. Git baseline: 15c6308cf7ad276b306aa5b3ababfbdebfb1a917; setup.c setup_git_directory_gently_1(), is_git_directory(), and validate_headref(). Repository validation can use GIT_COMMON_DIR for refs and objects. Preserve the same value on Repo so later config, ref, and object access uses the directory that made discovery succeed. Capture GIT_COMMON_DIR before the first repository config read so bare-state detection uses the same metadata location as discovery. Resolve relative environment values immediately so later working-directory changes cannot retarget the Repo. Review feedback: relative GIT_COMMON_DIR left Git subprocesses resolving GIT_DIR and GIT_COMMON_DIR from a different working directory; malformed commondir data, empty GIT_OBJECT_DIRECTORY, and the linked-worktree signature were also handled inconsistently. Pin the repository environment to resolved paths, reject invalid metadata without consulting the process working directory, and restore HEAD-based linked-worktree detection. Keep the loose HEAD and dangling .git behavior because both match Git setup.c at baseline 15c6308cf7ad276b306aa5b3ababfbdebfb1a917. Review feedback identified that chained or self-referential .git pointers recurse, filesystem-encoded metadata can fail text decoding, and a relative GIT_DIR is not retained for later Git commands. Parse one regular, size-bounded Gitfile exactly once, decode Gitfile and commondir paths with the filesystem codec, and retain the resolved GIT_DIR for subprocesses. This rejects cycles like Git instead of recursing and keeps commands stable after working-directory changes. Review feedback noted that a dangling commondir symlink was treated as absent, allowing local objects and refs to validate the repository. Distinguish a truly missing commondir from a dangling symlink. This follows Git's get_common_dir_noenv(), whose file_exists check uses lstat before attempting to read the entry. Python 3.9 on Windows raised UnicodeDecodeError while the repository-discovery regression test parsed invalid commondir bytes, causing the Python package test (windows, 3.9) check to fail. Treat UnicodeError like an unreadable metadata file in both commondir and gitfile parsing. Invalid bytes now make discovery reject the candidate repository, matching Git's behavior. Review feedback noted that GIT_OBJECT_DIRECTORY made discovery succeed without becoming the Repo ODB root, while a relative value could later be resolved from the Git wrapper's different working directory. Resolve the environment value against the construction directory, use it as the ODB root, and preserve the absolute value for later Git commands. The regression moves the only object store outside the git directory and verifies access through both GitDB and git cat-file after the original environment and current directory are restored. Review feedback identified four setup mismatches: non-missing .git stat failures could fall through to another repository, explicit GIT_DIR could be redirected through a nested .git entry, Gitfile reads were not bounded to the stat-reported size, and alternates ignored GIT_OBJECT_DIRECTORY. Match Git setup.c by bypassing discovery for an environment-selected GIT_DIR, stopping discovery when Gitfile stat fails for reasons other than a missing path, and reading exactly the previously observed Gitfile size. Resolve alternates below the active ODB root so custom object stores remain internally consistent. The commit review noted that treating every present GIT_DIR as explicit broke two documented cases: an empty GIT_DIR must fall back to current-directory discovery, while an empty Repo path must still use a nonempty GIT_DIR. Assisted-by: GPT 5.6 Co-authored-by: GPT 5.6 <codex@openai.com>
| Back | FazBrowse Home | New Git URL |
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
Everything below this line was generated by Codex GPT-5.
Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Advisory
https://github.com/gitpython-developers/GitPython/security/advisories/GHSA-239g-whfq-7xj9
GHSA-239g-whfq-7xj9 reports that repository content can be mistaken for repository metadata when GitPython opens a normal worktree.
Advisory summary
Changes
Git baseline: 15c6308cf7ad276b306aa5b3ababfbdebfb1a917, especially setup.c setup_git_directory_gently_1(), is_git_directory(), validate_headref(), read_gitfile_gently(), and get_common_dir_noenv().
Validation
Commits