Add an update=none option for 'loose' submodules
cover Add an update=none option for 'loose' submodules
If a submodule is used to seperate some bigger parts of a project into an optional directory it is helpful to not clone/update them by default.
This series implements a new value 'none' for submodule.<name>.update. If this option is set a submodule will not be updated or cloned by default. If the user wants to work with the submodule he either needs to explicitely configure the update option to 'checkout' or pass --checkout as an option to the submodules. I chose this name to be consistent with the existing --merge/--rebase options.
What do you think about this approach?
If we agree that this is the correct way to approach this use case I would proceed to implement tests and documentation.
Cheers Heiko
Heiko Voigt (2):
submodule: move update configuration variable further up add update 'none' flag to disable update of submodule by default
git-submodule.sh | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.5.1.219.g4c6b2
RFC PATCH 1/2 submodule: move update configuration variable further up
Lets always initialize the 'update_module' variable with the final value. This way we allow code which wants to check this configuration early to do so right in the beginning of cmd_update().
--- git-submodule.sh | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
git-submodule.sh +7 -6
@@ -454,7 +454,13 @@ cmd_update() fi name=$(module_name "$path") || exit url=$(git config submodule."$name".url) - update_module=$(git config submodule."$name".update) + if ! test -z "$update" + then + update_module=$update + else + update_module=$(git config submodule."$name".update) + fi + if test -z "$url" then # Only mention uninitialized submodules when its
@@ -476,11 +482,6 @@ cmd_update() die "Unable to find current revision in submodule path '$path'" fi - if ! test -z "$update" - then - update_module=$update - fi - if test "$subsha1" != "$sha1" then subforce=$force
Signature · 1 line
1.7.5.1.219.g4c6b2
RFC PATCH 2/2 add update 'none' flag to disable update of submodule by default
In reply to Heiko VoigtThis is useful to mark a submodule as unneeded by default. When this option is set and the user wants to work with such a submodule he needs to configure 'submodule.<name>.update=checkout' or pass the --checkout option. Then the submodule can be handled like a normal submodule.
TODO: Documentation/Tests
--- git-submodule.sh | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
git-submodule.sh +9 -0
@@ -423,6 +423,9 @@ cmd_update() --recursive) recursive=1 ;; + --checkout) + update="checkout" + ;; --) shift break
@@ -461,6 +464,12 @@ cmd_update() update_module=$(git config submodule."$name".update) fi + if test "$update_module" = "none" + then + echo "Skipping submodule '$path'" + continue + fi + if test -z "$url" then # Only mention uninitialized submodules when its
Signature · 1 line
1.7.5.1.219.g4c6b2
Am 06.06.2011 22:57, schrieb Heiko Voigt:
Quoted 2 lines
If a submodule is used to seperate some bigger parts of a project into an optional directory it is helpful to not clone/update them by default.
I think this is a good idea as some people are running "git submodule update --init --recursive" when they have to update their submodules. It would be nice to have an option to skip certain submodules then.
Quoted 8 lines
This series implements a new value 'none' for submodule.<name>.update. If this option is set a submodule will not be updated or cloned by default. If the user wants to work with the submodule he either needs to explicitely configure the update option to 'checkout' or pass --checkout as an option to the submodules. I chose this name to be consistent with the existing --merge/--rebase options.
What do you think about this approach?
It fits in nicely with my long term plan: Let the "update" flag control what happens on submodule checkout in the work tree. Another flag ("init"?) can be added later to control if a submodule should be initialized on clone or update, but that is outside the scope of this change.
Quoted 2 lines
If we agree that this is the correct way to approach this use case I would proceed to implement tests and documentation.
+1 from me.