Skip to content

Skip .gitmodules entries that have no gitlink - #5

Merged
mbid merged 3 commits into
NVIDIA:mainfrom
MaxFreedomPollard:skip-stale-gitmodules-entries
Oct 13, 2026
Merged

mbid merged 3 commits into
NVIDIA:mainfrom
MaxFreedomPollard:skip-stale-gitmodules-entries

Conversation

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor

Fixes #2.

Pod setup took the list of submodules from .gitmodules alone and ran git submodule init <path> for each entry. For a section left behind after its submodule was removed from the tree, that fails with pathspec ... did not match any file(s) known to git and aborts the whole container setup.

detect_submodules_from_gitmodules now keeps only the entries whose path the index records as a gitlink (mode 160000 in git ls-files --stage), which is what git itself treats as a submodule, and warns on stderr about the ones it skips. --literal-pathspecs keeps a submodule path with glob characters from being read as a pattern. The function returns a Result now, so a failing index lookup stops setup instead of silently dropping every submodule. Nothing changes on the host side, where git submodule foreach already visits gitlinks only.

Testing

New integration test stale_gitmodules_entry_does_not_break_setup: a repo with one real submodule and one stale section. It asserts that rumpel enter succeeds and that the real submodule is checked out at the commit the parent records.

I ran the full pipeline through the CI workflow on my fork, once with only the new test and once with the fix:

  • test only: the new test fails with submodule setup failed: ... "git" "submodule" "init" "removed", 617 passed and 1 failed on linux-amd64. The linux-arm64 job also had codex_permissions_new_threads_keep_default_bypass fail, which passed in the other three runs.
  • test and fix: 618 passed, 0 failed on linux-amd64 and linux-arm64, and macos-arm64 builds.

One note: CONTRIBUTING.md says to open pull requests against master, but the default branch is main, so this targets main.

MaxFreedomPollard and others added 3 commits September 19, 2026 02:13
Removing a submodule from the tree can leave its .gitmodules section
behind. Git ignores such an entry, but pod setup took the submodule
list from .gitmodules alone and ran `git submodule init <path>` for
each one, which fails when the path is not a gitlink and aborted the
whole container setup.

Only keep entries whose path the index records as a gitlink, which is
what git itself treats as a submodule, and warn on stderr about the
rest. The detection now returns a Result so that a failing index
lookup stops setup instead of silently dropping every submodule.

Fixes NVIDIA#2

Signed-off-by: Max Freedom Pollard <272618364+MaxFreedomPollard@users.noreply.github.com>
Signed-off-by: Martin Bidlingmaier <bidlingmaier@nvidia.com>
Exercise regular-file and nested stale entries, and keep the restart fixture reaching the uninitialized-worktree guard after index filtering.

Signed-off-by: Martin Bidlingmaier <bidlingmaier@nvidia.com>
@mbid
mbid merged commit b3496bd into NVIDIA:main Oct 13, 2026
@mbid

mbid commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Merged, thanks Max!

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.

Submodule setup panics on stale .gitmodules entries (entry without gitlink)

2 participants