Skip to main content

Module update_strategy

Module update_strategy 

Source
Expand description

Submodule update-strategy resolution — a Rust port of git’s builtin/submodule--helper.c::determine_submodule_update_strategy plus the per-strategy execution dispatch (run_update_command).

submodule update must, for each selected submodule, pick exactly ONE update mode and run it against the gitlink oid recorded in the superproject index. git resolves the mode from a fixed precedence:

  1. the command-line --checkout/--merge/--rebase flag (the update default passed into update_submodule), if any;
  2. else .git/config submodule.<name>.update;
  3. else the .gitmodules submodule.<name>.update value parsed into the typed UpdateStrategy (but NOT a !command — git BUG()s if it ever reads a command out of .gitmodules, because init refuses to copy one);
  4. else UpdateType::Checkout.

Then a just_cloned submodule downgrades merge/rebase/none to checkout (there is no local HEAD to merge/rebase onto yet).

Centralizing this here means the CLI’s submodule update routes every mode through one resolver + one dispatch, so the whole update CLASS (checkout, merge, rebase, command, none-skip) converges on a single code path instead of the old checkout-only special case.

Functions§

determine_update_strategy
Port of determine_submodule_update_strategy. Resolves the effective update strategy for one submodule from the precedence above.