threads / patch / 20420

patchMake 'submodule update' honor the 'update' setting in .gitmodules.

Subject: [PATCH] Make 'submodule update' honor the 'update' setting in .gitmodules.

## tl;dr

2 messages between Aug 6, 2009 and Aug 7, 2009. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Mikhail Glushenkov· Aug 6, 2009, 03:56 UTC · lore

Make the 'submodule update' command honor the 'submodule.$path.update' setting in .gitmodules unless this setting is overridden in '.git/config' or with --rebase/--merge options.

Signed-off-by: Mikhail Glushenkov <foldr@codedgers.com>
---
 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 ebed711..636023a 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -372,6 +372,15 @@ cmd_update()
 		name=$(module_name "$path") || exit
 		url=$(git config submodule."$name".url)
 		update_module=$(git config submodule."$name".update)
+
+		if test -z "$update_module"
+		then
+		    update_module="$(git config -f .gitmodules submodule."$name".update)"
+		    test -z "$update_module" ||
+		    git config submodule."$name".update "$update_module" ||
+		    die "Failed to register update mode for submodule path '$path'"
+		fi
+
 		if test -z "$url"
 		then
 			# Only mention uninitialized submodules when its
-- 
1.6.4
Junio C Hamano· Aug 7, 2009, 21:54 UTC · re: Mikhail Glushenkov · lore

Re: [PATCH] Make 'submodule update' honor the 'update' setting in .gitmodules.

Mikhail Glushenkov <foldr@codedgers.com> writes:
> Make the 'submodule update' command honor the 'submodule.$path.update' setting
> in .gitmodules unless this setting is overridden in '.git/config' or with
> --rebase/--merge options.

I haven't been involved in recent updates to "git submodule", but the change in this patch feels somewhat wrong.

The contents of in-tree .gitmodules are meant to be consulted to only prime the settings in .git/config, and after that they are never used without user's explicit concent (e.g. "sync"). At least that is the way I understand how the current "git submodule" command is designed.

This change actively breaks the pattern. It makes sense to set up values for "submodule.*.update" when the defaults suggested by the project are copied out of .gitmodules to prime .git/config upon "submodule init", but not at runtime in "update" command like this.

I am puzzled.  What problem are you trying to solve?

"submodule init" seems to already copy "update" setting from .gitmodules to .git/config. At least, it seems to have a code to try to do so.

Perhaps you would want to (1) add the "submodule.*.update" to the set of configurations to be copied upon "sync", not just URL? and (2) add a way to allow users to inspect how values in .git/config and .gitmodules are different, and update .git/config with selected values, possibly in an interactive manner?

← back to recent threads