[RFC PATCH 0/2] Add an update=none option for 'loose' submodules

STALE3737d

Revision rfc of 2 in this series.

4 messages, 2 authors, 2016-06-15 · open the first message on its own page

[RFC PATCH 0/2] Add an update=none option for 'loose' submodules

From: Heiko Voigt <hidden>
Date: 2016-06-15 22:51:25

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(-)

-- 
1.7.5.1.219.g4c6b2

[RFC PATCH 1/2] submodule: move update configuration variable further up

From: Heiko Voigt <hidden>
Date: 2016-06-15 22:51:25

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(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index d189a24..70dfc7b 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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
-- 
1.7.5.1.219.g4c6b2

[RFC PATCH 2/2] add update 'none' flag to disable update of submodule by default

From: Heiko Voigt <hidden>
Date: 2016-06-15 22:51:25

This 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(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 70dfc7b..77977b5 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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
-- 
1.7.5.1.219.g4c6b2

Re: [RFC PATCH 0/2] Add an update=none option for 'loose' submodules

From: Jens Lehmann <hidden>
Date: 2016-06-15 22:51:27

Am 06.06.2011 22:57, schrieb Heiko Voigt:
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.
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.
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help