Repository navigation
Resolve relative local submodule origins against the owning workdir - #127
Conversation
Co-authored-by: Codex <noreply@openai.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c085d4a9d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
odrobnik
left a comment
There was a problem hiding this comment.
No findings.
The shim sends submodule.c's single git_fs_path_apply_relative call (in git_submodule__resolve_url, where repo is in scope) through a wrapper. When the base URL is a relative local path, the wrapper first joins it to the owning repository's workdir. All three callers go through that one function — add_setup, init and sync — so they are all covered. fs_path.h is included before the macro is defined, so its declaration of the function is not rewritten.
What I checked:
..in the base.git_fs_path_apply_relativejoins and then runsgit_fs_path_resolve_relativeover the whole path. A..that the workdir join puts into the base is therefore normalized correctly, including when the relative URL climbs above it.- Which origins count as local. A separator before the first colon means a local path; otherwise it is left alone. This matches git's
url_is_local_not_sshon POSIX. Rooted paths, URLs and SCP-style origins resolve as before. - Defaults. When there is no remote, libgit2 falls back to the workdir or the parent's worktree path. Both are already absolute, so they are unaffected.
- Memory and errors. The
git_strswap and dispose are correct on both the success and error paths. - Fit with git. git fetches from the top of the worktree, so anchoring to the workdir matches how git itself resolves a relative remote.
Two behaviour changes, both acceptable:
- Bare repositories. A bare repository with a relative local origin now fails with a bare-repository error. Before, it returned a path that depended on the process's current directory. Failing seems safer.
- Absolute URLs. The superproject and child configs now store absolute URLs, as issue #126 asks.
The tests cover what the issue asks for: a different process cwd, initial and repeated recursive sync each followed by a fetch, nested submodules, and a nested repository's own relative origin.
The test changes the process-wide cwd, and .serialized only orders tests inside this suite, not across suites. I checked every Process() in Tests/GitKitTests. Each one either sets currentDirectoryURL or uses an absolute executable with absolute arguments. I found no test that resolves paths against cwd. Running that check took a second attempt, because one combined shell command was refused. Everything listed here was then inspected in full.
Not covered: the Windows-specific paths (backslash and drive-relative origins) were checked by reading the code only. The new tests run only on macOS and Linux. CI lint was still pending at review time.
👍 No findings.
Reviewed by Claude · opus
Resolves #126.
Submodule sync now resolves relative local origins against each owning repository's working directory, including nested submodules. The regression reproduces the original failure and now passes, and all macOS tests and code checks passed; Linux and Windows were not built locally. The change is ready for automated review.