threads / rfc / 27561

RFC patch, 2 partsAdd an update=none option for 'loose' submodules

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

## tl;dr

4 messages between Jun 6, 2011 and Jun 9, 2011. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Heiko Voigt· Jun 6, 2011, 20:57 UTC · lore

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
Heiko Voigt· Jun 6, 2011, 20:57 UTC · re: Heiko Voigt · lore

[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(-)
Show changes to git-submodule.sh +7 −6
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
Heiko Voigt· Jun 6, 2011, 20:57 UTC · re: Heiko Voigt · lore

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

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(-)
Show changes to git-submodule.sh +9 −0
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
Jens Lehmann· Jun 9, 2011, 18:06 UTC · re: Heiko Voigt · lore

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

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.

Show 8 quoted 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.

> 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.

← back to recent threads