All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] git-submodule.sh: Always initialize $url variable
@ 2012-05-28  9:41 Nicolas Viennot and Sid Nair
  2012-05-28 19:46 ` [PATCH] submodules: print "registered for path" message only once Jens Lehmann
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Viennot and Sid Nair @ 2012-05-28  9:41 UTC (permalink / raw)
  To: git, Junio C Hamano
  Cc: Nicolas Viennot and Sid Nair, Jens Lehmann, Ramsay Jones,
	Nicolas Viennot, Sid Nair

When git submodule init was called, the $url variable was not initialized
properly for submodules which have already been initialized. This led
to two problems.

First, when all of the submodules were initialized, each showed an empty url
instead of the actual url.

Second, when previously initialized submodules were printed after newly
added submodules, the displayed urls were incorrect.

Cc: Jens Lehmann <Jens.Lehmann@web.de>
Cc: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Nicolas Viennot <nicolas@viennot.biz>
Signed-off-by: Sid Nair <sidnair09@gmail.com>
---
 git-submodule.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 64a70d6..92fd6e2 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -396,11 +396,11 @@ cmd_init()
 	module_list "$@" |
 	while read mode sha1 stage sm_path
 	do
-		# Skip already registered paths
 		name=$(module_name "$sm_path") || exit
+		url=$(git config -f .gitmodules submodule."$name".url)
+		# Skip already registered paths
 		if test -z "$(git config "submodule.$name.url")"
 		then
-			url=$(git config -f .gitmodules submodule."$name".url)
 			test -z "$url" &&
 			die "$(eval_gettext "No url found for submodule path '\$sm_path' in .gitmodules")"
 
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] submodules: print "registered for path" message only once
  2012-05-28  9:41 [PATCH] git-submodule.sh: Always initialize $url variable Nicolas Viennot and Sid Nair
@ 2012-05-28 19:46 ` Jens Lehmann
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Lehmann @ 2012-05-28 19:46 UTC (permalink / raw)
  To: Nicolas Viennot and Sid Nair
  Cc: git, Junio C Hamano, Nicolas Viennot and Sid Nair, Ramsay Jones,
	Nicolas Viennot, Sid Nair, Heiko Voigt

Since 2cd9de3e (submodule add: always initialize .git/config entry) the
message "Submodule '\$name' (\$url) registered for path '\$sm_path'" is
printed every time cmd_init() is called, e.g. each time "git submodule
update" is used with the --init option.

This was not intended and leads to bogus output which can confuse users
and build systems. Apart from that the $url variable was not set after the
first run which did the actual initialization and only "()" was printed
in subsequent runs where "($url)" was meant to inform the user about the
upstream repo.

Fix that by moving the say command in question into the if block where the
url is initialized, restoring the behavior that was in place before the
2cd9de3e commit. While at it also remove the comment which still describes
the logic used before 2cd9de3e and add a comment about how things work now.

Reported-by: Nicolas Viennot and Sid Nair <nicolas@viennot.com>
Reported-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---

Am 28.05.2012 11:41, schrieb Nicolas Viennot and Sid Nair:
> When git submodule init was called, the $url variable was not initialized
> properly for submodules which have already been initialized. This led
> to two problems.
> 
> First, when all of the submodules were initialized, each showed an empty url
> instead of the actual url.
> 
> Second, when previously initialized submodules were printed after newly
> added submodules, the displayed urls were incorrect.

Thanks for pointing this one out. Me thinks the real culprit here is to
print the "registered for path" message even though that was not what
was done. This popped up last week at $dayjob and I just got around to
do this fix when your patch appeared on the list ;-)


 git-submodule.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 64a70d6..5c61ae2 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -396,8 +396,9 @@ cmd_init()
 	module_list "$@" |
 	while read mode sha1 stage sm_path
 	do
-		# Skip already registered paths
 		name=$(module_name "$sm_path") || exit
+
+		# Copy url setting when it is not set yet
 		if test -z "$(git config "submodule.$name.url")"
 		then
 			url=$(git config -f .gitmodules submodule."$name".url)
@@ -412,6 +413,8 @@ cmd_init()
 			esac
 			git config submodule."$name".url "$url" ||
 			die "$(eval_gettext "Failed to register url for submodule path '\$sm_path'")"
+
+			say "$(eval_gettext "Submodule '\$name' (\$url) registered for path '\$sm_path'")"
 		fi

 		# Copy "update" setting when it is not set yet
@@ -420,8 +423,6 @@ cmd_init()
 		test -n "$(git config submodule."$name".update)" ||
 		git config submodule."$name".update "$upd" ||
 		die "$(eval_gettext "Failed to register update mode for submodule path '\$sm_path'")"
-
-		say "$(eval_gettext "Submodule '\$name' (\$url) registered for path '\$sm_path'")"
 	done
 }

-- 
1.7.11.rc0.dirty

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-28 19:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-28  9:41 [PATCH] git-submodule.sh: Always initialize $url variable Nicolas Viennot and Sid Nair
2012-05-28 19:46 ` [PATCH] submodules: print "registered for path" message only once Jens Lehmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.