git: submodule, Add relative URL regression tests#2072
Merged
Conversation
pjbgf
reviewed
May 7, 2026
8351a85 to
79874d1
Compare
Mirror the regression-test coverage from v5 PR go-git#2070 (54a3234) to v6. The v5 commit fixed `Submodule.Repository()` to resolve relative submodule URLs such as `../X.git` against the parent repository's remote URL per git-submodule(1)[1] and canonical Git, rather than absolutizing them against the process CWD. The v5 root cause — `transport.NewEndpoint` running scheme-less inputs through `parseFile`, which called `filepath.Abs` — does not exist on v6: `internal/url.ParseFile` stores the input verbatim. The relative-resolution branch in `Submodule.Repository()` therefore already fires correctly, and PR go-git#2071 (0d02124) plus PR go-git#2076 (1655810) further hardened remote selection via `defaultRemote` and `lookupRemote`. So the production code on v6 already has the fix; this commit only backfills the matching test coverage so a future refactor that reintroduces eager normalization in `ParseFile` fails loudly instead of silently breaking submodule resolution. Five table-driven cases cover relative URLs against HTTPS and SSH parents, deep traversal (`../../`), absolute local URL preservation, and the no-parent-remote case. The last asserts the `defaultRemote`-wrapped error `resolving relative submodule URL: remote "origin" not found`, matching v5's `TestRepositoryRelativeURLNoParentRemote` after the same upstream remote-selection refactor landed there. [1]: https://git-scm.com/docs/git-submodule Assisted-by: Claude Opus 4.7 Signed-off-by: Hidde Beydals <[email protected]>
79874d1 to
0964dd8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported by @N0zoM1z0, thank you! 🙇
Mirror the v5 fix from PR #2070 (54a3234) to v6 as regression coverage. The v5 fix corrected
Submodule.Repository()to resolve relative submodule URLs such as../X.gitagainst the parent remote URL per git-submodule(1)1 and canonical Git, rather than absolutizing them against the process CWD.The v5 root cause —
transport.NewEndpointrunning scheme-less inputs throughparseFile, which calledfilepath.Abs— does not exist on v6:internal/url.ParseFilestores the input verbatim, so the relative-resolution branch inSubmodule.Repository()already fires correctly. These tests lock that invariant in so a future refactor reintroducing eager normalization inParseFilefails loudly instead of silently breaking submodule resolution.Five tests cover relative URLs against HTTPS and SSH parents, deep traversal (
../../), absolute local URL preservation, and the no-parent-remote case. The last asserts an explicit error; v6 still had the unguardedremotes[0]access that PR #2070 replaced, so port the matching guard alongside the tests.