Skip to content

Resolve relative local submodule origins against the owning workdir - #127

Merged
odrobnik merged 3 commits into
mainfrom
agent/issue-126
Dec 1, 2026
Merged

odrobnik merged 3 commits into
mainfrom
agent/issue-126

Conversation

@odrobnik

@odrobnik odrobnik commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T19:18:22.150798Z 2c085d4 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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 odrobnik left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_relative joins and then runs git_fs_path_resolve_relative over 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_ssh on 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_str swap 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

@odrobnik
odrobnik merged commit fb12de5 into main Dec 1, 2026
6 of 8 checks passed
@odrobnik
odrobnik deleted the agent/issue-126 branch December 1, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resolve relative local origins against the owning workdir during submodule sync

1 participant