Skip to content

Add submodule update to the local layer #93

Description

@matt-edmondson

Written by Claude (Claude Code) on behalf of Matt Edmondson. The analysis and proposed shape below are Claude's, filed at Matt's request.

There is no way to check out the commits a superproject's gitlinks record, which is the operation git submodule update --init --recursive performs. grep -rn 'submodule' GitIntegration --include='*.cs' (excluding obj/) returns nothing.

Assumes submodules are now in scope for the local layer — see the submodule listing issue for the scope note.

Suggested shape

git submodule update produces only human prose, with no porcelain alternative. Per CLAUDE.md architecture point 8, that means it returns GitCompleted rather than a parsed result, exactly as Pull does. A caller who needs to know what moved asks Submodules() before and after.

  • IGitSubmoduleUpdateBuilder : IGitCommandBuilder<GitCompleted> in Builders/.
  • Options, each mapping to one git flag: Initialise() (--init), Recursive() (--recursive), FromRemote() (--remote, which uses the branch configured in .gitmodules instead of the recorded gitlink), Force() (--force), and WithDepth(int) (--depth) to match GitFetchBuilder and GitCloneBuilder.
  • ReportingProgress(IProgress<string>), since this is a network operation and the three existing network verbs (Fetch, Clone, Push) all offer it.
  • GitRepository.UpdateSubmodules().

The partial-state outcome deserves explicit documentation

A submodule update that fails after the superproject has already advanced leaves the repository in a state that is neither the old one nor the intended new one: the branch has moved, and one or more submodules are on the wrong commit. A caller that reports only the submodule failure implies the repository is untouched, which is wrong and actively misleading.

GitCommandException carries enough for a caller to act (exit code, argument vector, diagnostic), so a dedicated exception type is probably unnecessary. But the builder's remarks should state plainly that a failure here does not imply the superproject is unchanged, in the same spirit as GitPushBuilder's remarks explaining why its two entry points diverge. Without that note, the natural reading of an exception is "nothing happened", and here that reading is false.

Interaction with --recurse-submodules

pull --recurse-submodules and this verb overlap but are not equivalent: the flag updates submodules as part of the pull, whereas this verb also initialises newly added ones (--init), which the flag does on its own only from git 2.13 onward and only for submodules already registered in .gitmodules. Both are worth having. See the --recurse-submodules issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions