{"thread":{"id":"30640","subject":"[PATCH] git-submodule.sh: Always initialize $url variable","startedAt":"2012-05-28T09:41:54Z","lastAt":"2012-05-28T19:46:58Z","messageCount":2,"participants":["Nicolas Viennot and Sid Nair","Jens Lehmann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"192317","messageId":"1338198114-20480-1-git-send-email-nviennot+sidnair@viennot.biz","threadId":"30640","inReplyTo":null,"subject":"[PATCH] git-submodule.sh: Always initialize $url variable","fromName":"Nicolas Viennot and Sid Nair","fromEmail":"nicolas@viennot.com","sentAt":"2012-05-28T09:41:54Z","receivedAt":"2012-05-28T09:41:54Z","isPatch":true,"sender":{"key":"nicolas@viennot.com","avatar":null},"body":"When git submodule init was called, the $url variable was not initialized\nproperly for submodules which have already been initialized. This led\nto two problems.\n\nFirst, when all of the submodules were initialized, each showed an empty url\ninstead of the actual url.\n\nSecond, when previously initialized submodules were printed after newly\nadded submodules, the displayed urls were incorrect.\n\nCc: Jens Lehmann <Jens.Lehmann@web.de>\nCc: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\nSigned-off-by: Nicolas Viennot <nicolas@viennot.biz>\nSigned-off-by: Sid Nair <sidnair09@gmail.com>\n---\n git-submodule.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 64a70d6..92fd6e2 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -396,11 +396,11 @@ cmd_init()\n \tmodule_list \"$@\" |\n \twhile read mode sha1 stage sm_path\n \tdo\n-\t\t# Skip already registered paths\n \t\tname=$(module_name \"$sm_path\") || exit\n+\t\turl=$(git config -f .gitmodules submodule.\"$name\".url)\n+\t\t# Skip already registered paths\n \t\tif test -z \"$(git config \"submodule.$name.url\")\"\n \t\tthen\n-\t\t\turl=$(git config -f .gitmodules submodule.\"$name\".url)\n \t\t\ttest -z \"$url\" &&\n \t\t\tdie \"$(eval_gettext \"No url found for submodule path '\\$sm_path' in .gitmodules\")\"\n \n-- \n1.7.8.6\n"},{"id":"192395","messageId":"4FC3D632.6030604@web.de","threadId":"30640","inReplyTo":"1338198114-20480-1-git-send-email-nviennot+sidnair@viennot.biz","subject":"[PATCH] submodules: print \"registered for path\" message only once","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-05-28T19:46:58Z","receivedAt":"2012-05-28T19:46:58Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Since 2cd9de3e (submodule add: always initialize .git/config entry) the\nmessage \"Submodule '\\$name' (\\$url) registered for path '\\$sm_path'\" is\nprinted every time cmd_init() is called, e.g. each time \"git submodule\nupdate\" is used with the --init option.\n\nThis was not intended and leads to bogus output which can confuse users\nand build systems. Apart from that the $url variable was not set after the\nfirst run which did the actual initialization and only \"()\" was printed\nin subsequent runs where \"($url)\" was meant to inform the user about the\nupstream repo.\n\nFix that by moving the say command in question into the if block where the\nurl is initialized, restoring the behavior that was in place before the\n2cd9de3e commit. While at it also remove the comment which still describes\nthe logic used before 2cd9de3e and add a comment about how things work now.\n\nReported-by: Nicolas Viennot and Sid Nair <nicolas@viennot.com>\nReported-by: Heiko Voigt <hvoigt@hvoigt.net>\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n\nAm 28.05.2012 11:41, schrieb Nicolas Viennot and Sid Nair:\n> When git submodule init was called, the $url variable was not initialized\n> properly for submodules which have already been initialized. This led\n> to two problems.\n> \n> First, when all of the submodules were initialized, each showed an empty url\n> instead of the actual url.\n> \n> Second, when previously initialized submodules were printed after newly\n> added submodules, the displayed urls were incorrect.\n\nThanks for pointing this one out. Me thinks the real culprit here is to\nprint the \"registered for path\" message even though that was not what\nwas done. This popped up last week at $dayjob and I just got around to\ndo this fix when your patch appeared on the list ;-)\n\n\n git-submodule.sh | 7 ++++---\n 1 file changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 64a70d6..5c61ae2 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -396,8 +396,9 @@ cmd_init()\n \tmodule_list \"$@\" |\n \twhile read mode sha1 stage sm_path\n \tdo\n-\t\t# Skip already registered paths\n \t\tname=$(module_name \"$sm_path\") || exit\n+\n+\t\t# Copy url setting when it is not set yet\n \t\tif test -z \"$(git config \"submodule.$name.url\")\"\n \t\tthen\n \t\t\turl=$(git config -f .gitmodules submodule.\"$name\".url)\n@@ -412,6 +413,8 @@ cmd_init()\n \t\t\tesac\n \t\t\tgit config submodule.\"$name\".url \"$url\" ||\n \t\t\tdie \"$(eval_gettext \"Failed to register url for submodule path '\\$sm_path'\")\"\n+\n+\t\t\tsay \"$(eval_gettext \"Submodule '\\$name' (\\$url) registered for path '\\$sm_path'\")\"\n \t\tfi\n\n \t\t# Copy \"update\" setting when it is not set yet\n@@ -420,8 +423,6 @@ cmd_init()\n \t\ttest -n \"$(git config submodule.\"$name\".update)\" ||\n \t\tgit config submodule.\"$name\".update \"$upd\" ||\n \t\tdie \"$(eval_gettext \"Failed to register update mode for submodule path '\\$sm_path'\")\"\n-\n-\t\tsay \"$(eval_gettext \"Submodule '\\$name' (\\$url) registered for path '\\$sm_path'\")\"\n \tdone\n }\n\n-- \n1.7.11.rc0.dirty\n"}]}