{"thread":{"id":"42185","subject":"[PATCH 01/10] submodule deinit test: fix broken && chain in subshell","startedAt":"2016-04-30T00:40:35Z","lastAt":"2016-05-03T01:17:33Z","messageCount":20,"participants":["Stefan Beller","Per Cederqvist","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":10},"messages":[{"id":"285009","messageId":"1461976845-18228-1-git-send-email-sbeller@google.com","threadId":"42185","inReplyTo":null,"subject":"[PATCH 00/10] submodule output patches","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-30T00:40:35Z","receivedAt":"2016-04-30T00:40:35Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Patch 1 was send outside of a series already.\n\nPatch 2 and 3 are preparatory things for the submodule groups stuff\n\npatches 4-9 are making the output of the submodule command consistent\n(similar to patch 3, but I do not foresee a need for it yet)\n\nPatch 10 is a controversial thing I'd assume as it breaks existing users.\nWe should take it for the next major release (i.e. 3.0)\nI just want to put it out here now.\n\nThanks,\nStefan\n\nStefan Beller (10):\n  submodule deinit test: fix broken && chain in subshell\n  submodule deinit: lose requirement for giving '.'\n  submodule init: redirect stdout to stderr\n  shell helpers usage: always send help to stderr\n  submodule add: send messages to stderr\n  submodule deinit: send messages to stderr\n  submodule foreach: send messages to stderr\n  submodule update: send messages to stderr\n  submodule sync: send messages to stderr\n  submodule deinit: complain when given a file instead of a submodule\n\n builtin/submodule--helper.c  |  9 +++++----\n git-sh-setup.sh              |  2 +-\n git-submodule.sh             | 21 ++++++++-------------\n t/t7400-submodule-basic.sh   | 38 +++++++++++++++++++++++++-------------\n t/t7403-submodule-sync.sh    |  4 ++--\n t/t7406-submodule-update.sh  | 23 ++++++++++++++++-------\n t/t7407-submodule-foreach.sh | 35 ++++++++++++++++++++++-------------\n 7 files changed, 79 insertions(+), 53 deletions(-)\n\n-- \n2.8.0.32.g71f8beb.dirty\n"},{"id":"285008","messageId":"1461976845-18228-2-git-send-email-sbeller@google.com","threadId":"42185","inReplyTo":"1461976845-18228-1-git-send-email-sbeller@google.com","subject":"[PATCH 01/10] submodule deinit test: fix broken && chain in subshell","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-30T00:40:36Z","receivedAt":"2016-04-30T00:40:36Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Signed-off-by: Stefan Beller <sbeller@google.com>\n---\n t/t7400-submodule-basic.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 814ee63..90d80d3 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -914,7 +914,7 @@ test_expect_success 'submodule deinit works on repository without submodules' '\n \t\tgit init &&\n \t\t>file &&\n \t\tgit add file &&\n-\t\tgit commit -m \"repo should not be empty\"\n+\t\tgit commit -m \"repo should not be empty\" &&\n \t\tgit submodule deinit .\n \t)\n '\n-- \n2.8.0.32.g71f8beb.dirty\n"},{"id":"285010","messageId":"1461976845-18228-3-git-send-email-sbeller@google.com","threadId":"42185","inReplyTo":"1461976845-18228-1-git-send-email-sbeller@google.com","subject":"[PATCH 02/10] submodule deinit: lose requirement for giving '.'","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-30T00:40:37Z","receivedAt":"2016-04-30T00:40:37Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"The discussion in [1] realized that '.' is a faulty suggestion as\nthere is a corner case where it fails:\n\n> \"submodule deinit .\" may have \"worked\" in the sense that you would\n> have at least one path in your tree and avoided this \"nothing\n> matches\" most of the time.  It would have still failed with the\n> exactly same error if run in an empty repository, i.e.\n>\n>        $ E=/var/tmp/x/empty && rm -fr \"$E\" && mkdir -p \"$E\" && cd \"$E\"\n>        $ git init\n>        $ rungit v2.6.6 submodule deinit .\n>        error: pathspec '.' did not match any file(s) known to git.\n>        Did you forget to 'git add'?\n>        $ >file && git add file\n>        $ rungit v2.6.6 submodule deinit .\n>        $ echo $?\n>        0\n\nThere is no need to update the documentation as it did not describe the\nspecial case '.' to remove all submodules.\n\n[1] http://news.gmane.org/gmane.comp.version-control.git/289535\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n git-submodule.sh           | 5 -----\n t/t7400-submodule-basic.sh | 1 -\n 2 files changed, 6 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 82e95a9..d689265 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -428,11 +428,6 @@ cmd_deinit()\n \t\tshift\n \tdone\n \n-\tif test $# = 0\n-\tthen\n-\t\tdie \"$(eval_gettext \"Use '.' if you really want to deinitialize all submodules\")\"\n-\tfi\n-\n \tgit submodule--helper list --prefix \"$wt_prefix\" \"$@\" |\n \twhile read mode sha1 stage sm_path\n \tdo\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 90d80d3..a6231f1 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -948,7 +948,6 @@ test_expect_success 'submodule deinit . deinits all initialized submodules' '\n \tgit submodule update --init &&\n \tgit config submodule.example.foo bar &&\n \tgit config submodule.example2.frotz nitfol &&\n-\ttest_must_fail git submodule deinit &&\n \tgit submodule deinit . >actual &&\n \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n \ttest -z \"$(git config --get-regexp \"submodule\\.example2\\.\")\" &&\n-- \n2.8.0.32.g71f8beb.dirty\n"},{"id":"285013","messageId":"1461976845-18228-4-git-send-email-sbeller@google.com","threadId":"42185","inReplyTo":"1461976845-18228-1-git-send-email-sbeller@google.com","subject":"[PATCH 03/10] submodule init: redirect stdout to stderr","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-30T00:40:38Z","receivedAt":"2016-04-30T00:40:38Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Reroute the output of stdout to stderr as it is just informative\nmessages, not to be consumed by machines.\n\nWe want to init submodules from the helper for `submodule update`\nin a later patch and the stdout output of said helper is consumed\nby the parts of `submodule update` which are still written in shell.\nSo we have to be careful which messages are on stdout.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n builtin/submodule--helper.c |  3 ++-\n t/t7406-submodule-update.sh | 24 ++++++++++++++++++------\n 2 files changed, 20 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 5d05393..7f0941d 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -366,7 +366,8 @@ static void init_submodule(const char *path, const char *prefix, int quiet)\n \t\t\tdie(_(\"Failed to register url for submodule path '%s'\"),\n \t\t\t    displaypath);\n \t\tif (!quiet)\n-\t\t\tprintf(_(\"Submodule '%s' (%s) registered for path '%s'\\n\"),\n+\t\t\tfprintf(stderr,\n+\t\t\t\t_(\"Submodule '%s' (%s) registered for path '%s'\\n\"),\n \t\t\t\tsub->name, url, displaypath);\n \t}\n \ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex fd741f5..5f27879 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -108,24 +108,36 @@ pwd=$(pwd)\n \n cat <<EOF >expect\n Submodule path '../super': checked out '$supersha1'\n-Submodule 'merging' ($pwd/merging) registered for path '../super/merging'\n-Submodule 'none' ($pwd/none) registered for path '../super/none'\n-Submodule 'rebasing' ($pwd/rebasing) registered for path '../super/rebasing'\n-Submodule 'submodule' ($pwd/submodule) registered for path '../super/submodule'\n Submodule path '../super/merging': checked out '$mergingsha1'\n Submodule path '../super/none': checked out '$nonesha1'\n Submodule path '../super/rebasing': checked out '$rebasingsha1'\n Submodule path '../super/submodule': checked out '$submodulesha1'\n EOF\n \n+cat <<EOF >expect2\n+Submodule 'merging' ($pwd/merging) registered for path '../super/merging'\n+Submodule 'none' ($pwd/none) registered for path '../super/none'\n+Submodule 'rebasing' ($pwd/rebasing) registered for path '../super/rebasing'\n+Submodule 'submodule' ($pwd/submodule) registered for path '../super/submodule'\n+Cloning into '$pwd/recursivesuper/super/merging'...\n+done.\n+Cloning into '$pwd/recursivesuper/super/none'...\n+done.\n+Cloning into '$pwd/recursivesuper/super/rebasing'...\n+done.\n+Cloning into '$pwd/recursivesuper/super/submodule'...\n+done.\n+EOF\n+\n test_expect_success 'submodule update --init --recursive from subdirectory' '\n \tgit -C recursivesuper/super reset --hard HEAD^ &&\n \t(cd recursivesuper &&\n \t mkdir tmp &&\n \t cd tmp &&\n-\t git submodule update --init --recursive ../super >../../actual\n+\t git submodule update --init --recursive ../super >../../actual 2>../../actual2\n \t) &&\n-\ttest_cmp expect actual\n+\ttest_cmp expect actual &&\n+\ttest_cmp expect2 actual2\n '\n \n apos=\"'\";\n-- \n2.8.0.32.g71f8beb.dirty\n"},{"id":"285011","messageId":"1461976845-18228-5-git-send-email-sbeller@google.com","threadId":"42185","inReplyTo":"1461976845-18228-1-git-send-email-sbeller@google.com","subject":"[PATCH 04/10] shell helpers usage: always send help to stderr","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-30T00:40:39Z","receivedAt":"2016-04-30T00:40:39Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"`git submodule asdf` would trigger displaying the usage of the submodule\ncommand on stderr, however `git submodule -h` would display the usage on\nstdout. Unify displaying help for shell commands on stderr.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n git-sh-setup.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex c48139a..5c02446 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -65,7 +65,7 @@ say () {\n \n if test -n \"$OPTIONS_SPEC\"; then\n \tusage() {\n-\t\t\"$0\" -h\n+\t\t\"$0\" -h 1>&2\n \t\texit 1\n \t}\n \n-- \n2.8.0.32.g71f8beb.dirty\n"},{"id":"285016","messageId":"1461976845-18228-6-git-send-email-sbeller@google.com","threadId":"42185","inReplyTo":"1461976845-18228-1-git-send-email-sbeller@google.com","subject":"[PATCH 05/10] submodule add: send messages to stderr","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-30T00:40:40Z","receivedAt":"2016-04-30T00:40:40Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Reroute the output of stdout to stderr as it is just informative\nmessages, not to be consumed by machines.\n\nThis should not regress any scripts that try to parse the\ncurrent output, as the output is already internationalized\nand therefore unstable.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n git-submodule.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex d689265..f4d500e 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -271,7 +271,7 @@ Use -f if you really want to add it.\" >&2\n \t\t\t\techo >&2 \"$(eval_gettext \"use the '--force' option. If the local git directory is not the correct repo\")\"\n \t\t\t\tdie \"$(eval_gettext \"or you are unsure what this means choose another name with the '--name' option.\")\"\n \t\t\telse\n-\t\t\t\techo \"$(eval_gettext \"Reactivating local git directory for submodule '\\$sm_name'.\")\"\n+\t\t\t\techo >&2 \"$(eval_gettext \"Reactivating local git directory for submodule '\\$sm_name'.\")\"\n \t\t\tfi\n \t\tfi\n \t\tgit submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" \"$reference\" \"$depth\" || exit\n-- \n2.8.0.32.g71f8beb.dirty\n"},{"id":"285017","messageId":"1461976845-18228-7-git-send-email-sbeller@google.com","threadId":"42185","inReplyTo":"1461976845-18228-1-git-send-email-sbeller@google.com","subject":"[PATCH 06/10] submodule deinit: send messages to stderr","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-30T00:40:41Z","receivedAt":"2016-04-30T00:40:41Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Reroute the output of stdout to stderr as it is just informative\nmessages, not to be consumed by machines.\n\nThis should not regress any scripts that try to parse the\ncurrent output, as the output is already internationalized\nand therefore unstable.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n git-submodule.sh           |  8 ++++----\n t/t7400-submodule-basic.sh | 20 ++++++++++----------\n 2 files changed, 14 insertions(+), 14 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex f4d500e..3f67f4e 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -452,11 +452,11 @@ cmd_deinit()\n \t\t\t\tdie \"$(eval_gettext \"Submodule work tree '\\$displaypath' contains local modifications; use '-f' to discard them\")\"\n \t\t\tfi\n \t\t\trm -rf \"$sm_path\" &&\n-\t\t\tsay \"$(eval_gettext \"Cleared directory '\\$displaypath'\")\" ||\n-\t\t\tsay \"$(eval_gettext \"Could not remove submodule work tree '\\$displaypath'\")\"\n+\t\t\tsay >&2 \"$(eval_gettext \"Cleared directory '\\$displaypath'\")\" ||\n+\t\t\tsay >&2 \"$(eval_gettext \"Could not remove submodule work tree '\\$displaypath'\")\"\n \t\tfi\n \n-\t\tmkdir \"$sm_path\" || say \"$(eval_gettext \"Could not create empty submodule directory '\\$displaypath'\")\"\n+\t\tmkdir \"$sm_path\" || say >&2 \"$(eval_gettext \"Could not create empty submodule directory '\\$displaypath'\")\"\n \n \t\t# Remove the .git/config entries (unless the user already did it)\n \t\tif test -n \"$(git config --get-regexp submodule.\"$name\\.\")\"\n@@ -465,7 +465,7 @@ cmd_deinit()\n \t\t\t# the user later decides to init this submodule again\n \t\t\turl=$(git config submodule.\"$name\".url)\n \t\t\tgit config --remove-section submodule.\"$name\" 2>/dev/null &&\n-\t\t\tsay \"$(eval_gettext \"Submodule '\\$name' (\\$url) unregistered for path '\\$displaypath'\")\"\n+\t\t\tsay >&2 \"$(eval_gettext \"Submodule '\\$name' (\\$url) unregistered for path '\\$displaypath'\")\"\n \t\tfi\n \tdone\n }\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex a6231f1..53644da 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -935,7 +935,7 @@ test_expect_success 'submodule deinit from subdirectory' '\n \tmkdir -p sub &&\n \t(\n \t\tcd sub &&\n-\t\tgit submodule deinit ../init >../output\n+\t\tgit submodule deinit ../init 2>../output\n \t) &&\n \tgrep \"\\\\.\\\\./init\" output &&\n \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n@@ -948,7 +948,7 @@ test_expect_success 'submodule deinit . deinits all initialized submodules' '\n \tgit submodule update --init &&\n \tgit config submodule.example.foo bar &&\n \tgit config submodule.example2.frotz nitfol &&\n-\tgit submodule deinit . >actual &&\n+\tgit submodule deinit . 2>actual &&\n \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n \ttest -z \"$(git config --get-regexp \"submodule\\.example2\\.\")\" &&\n \ttest_i18ngrep \"Cleared directory .init\" actual &&\n@@ -959,7 +959,7 @@ test_expect_success 'submodule deinit . deinits all initialized submodules' '\n test_expect_success 'submodule deinit deinits a submodule when its work tree is missing or empty' '\n \tgit submodule update --init &&\n \trm -rf init example2/* example2/.git &&\n-\tgit submodule deinit init example2 >actual &&\n+\tgit submodule deinit init example2 2>actual &&\n \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n \ttest -z \"$(git config --get-regexp \"submodule\\.example2\\.\")\" &&\n \ttest_i18ngrep ! \"Cleared directory .init\" actual &&\n@@ -973,7 +973,7 @@ test_expect_success 'submodule deinit fails when the submodule contains modifica\n \ttest_must_fail git submodule deinit init &&\n \ttest -n \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n \ttest -f example2/.git &&\n-\tgit submodule deinit -f init >actual &&\n+\tgit submodule deinit -f init 2>actual &&\n \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n \ttest_i18ngrep \"Cleared directory .init\" actual &&\n \trmdir init\n@@ -985,7 +985,7 @@ test_expect_success 'submodule deinit fails when the submodule contains untracke\n \ttest_must_fail git submodule deinit init &&\n \ttest -n \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n \ttest -f example2/.git &&\n-\tgit submodule deinit -f init >actual &&\n+\tgit submodule deinit -f init 2>actual &&\n \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n \ttest_i18ngrep \"Cleared directory .init\" actual &&\n \trmdir init\n@@ -1000,7 +1000,7 @@ test_expect_success 'submodule deinit fails when the submodule HEAD does not mat\n \ttest_must_fail git submodule deinit init &&\n \ttest -n \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n \ttest -f example2/.git &&\n-\tgit submodule deinit -f init >actual &&\n+\tgit submodule deinit -f init 2>actual &&\n \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n \ttest_i18ngrep \"Cleared directory .init\" actual &&\n \trmdir init\n@@ -1008,17 +1008,17 @@ test_expect_success 'submodule deinit fails when the submodule HEAD does not mat\n \n test_expect_success 'submodule deinit is silent when used on an uninitialized submodule' '\n \tgit submodule update --init &&\n-\tgit submodule deinit init >actual &&\n+\tgit submodule deinit init 2>actual &&\n \ttest_i18ngrep \"Submodule .example. (.*) unregistered for path .init\" actual &&\n \ttest_i18ngrep \"Cleared directory .init\" actual &&\n-\tgit submodule deinit init >actual &&\n+\tgit submodule deinit init 2>actual &&\n \ttest_i18ngrep ! \"Submodule .example. (.*) unregistered for path .init\" actual &&\n \ttest_i18ngrep \"Cleared directory .init\" actual &&\n-\tgit submodule deinit . >actual &&\n+\tgit submodule deinit . 2>actual &&\n \ttest_i18ngrep ! \"Submodule .example. (.*) unregistered for path .init\" actual &&\n \ttest_i18ngrep \"Submodule .example2. (.*) unregistered for path .example2\" actual &&\n \ttest_i18ngrep \"Cleared directory .init\" actual &&\n-\tgit submodule deinit . >actual &&\n+\tgit submodule deinit . 2>actual &&\n \ttest_i18ngrep ! \"Submodule .example. (.*) unregistered for path .init\" actual &&\n \ttest_i18ngrep ! \"Submodule .example2. (.*) unregistered for path .example2\" actual &&\n \ttest_i18ngrep \"Cleared directory .init\" actual &&\n-- \n2.8.0.32.g71f8beb.dirty\n"},{"id":"285015","messageId":"1461976845-18228-8-git-send-email-sbeller@google.com","threadId":"42185","inReplyTo":"1461976845-18228-1-git-send-email-sbeller@google.com","subject":"[PATCH 07/10] submodule foreach: send messages to stderr","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-30T00:40:42Z","receivedAt":"2016-04-30T00:40:42Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Reroute the output of stdout to stderr as it is just informative\nmessages, not to be consumed by machines.\n\nThis should not regress any scripts that try to parse the\ncurrent output, as the output is already internationalized\nand therefore unstable.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n git-submodule.sh             |  2 +-\n t/t7407-submodule-foreach.sh | 35 ++++++++++++++++++++++-------------\n 2 files changed, 23 insertions(+), 14 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 3f67f4e..80270db 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -341,7 +341,7 @@ cmd_foreach()\n \t\tif test -e \"$sm_path\"/.git\n \t\tthen\n \t\t\tdisplaypath=$(relative_path \"$prefix$sm_path\")\n-\t\t\tsay \"$(eval_gettext \"Entering '\\$displaypath'\")\"\n+\t\t\tsay >&2 \"$(eval_gettext \"Entering '\\$displaypath'\")\"\n \t\t\tname=$(git submodule--helper name \"$sm_path\")\n \t\t\t(\n \t\t\t\tprefix=\"$prefix$sm_path/\"\ndiff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh\nindex 6ba5daf..f9b979a 100755\n--- a/t/t7407-submodule-foreach.sh\n+++ b/t/t7407-submodule-foreach.sh\n@@ -61,29 +61,36 @@ sub3sha1=$(cd super/sub3 && git rev-parse HEAD)\n \n pwd=$(pwd)\n \n-cat > expect <<EOF\n-Entering 'sub1'\n+cat >expect <<EOF\n $pwd/clone-foo1-sub1-$sub1sha1\n-Entering 'sub3'\n $pwd/clone-foo3-sub3-$sub3sha1\n EOF\n \n+cat >expect2 <<EOF\n+Entering 'sub1'\n+Entering 'sub3'\n+EOF\n+\n test_expect_success 'test basic \"submodule foreach\" usage' '\n \tgit clone super clone &&\n \t(\n \t\tcd clone &&\n \t\tgit submodule update --init -- sub1 sub3 &&\n-\t\tgit submodule foreach \"echo \\$toplevel-\\$name-\\$path-\\$sha1\" > ../actual &&\n+\t\tgit submodule foreach \"echo \\$toplevel-\\$name-\\$path-\\$sha1\" >../actual 2>../actual2 &&\n \t\tgit config foo.bar zar &&\n \t\tgit submodule foreach \"git config --file \\\"\\$toplevel/.git/config\\\" foo.bar\"\n \t) &&\n-\ttest_i18ncmp expect actual\n+\ttest_i18ncmp expect actual &&\n+\ttest_i18ncmp expect2 actual2\n '\n \n-cat >expect <<EOF\n+cat >expect2 <<EOF\n Entering '../sub1'\n-$pwd/clone-foo1-../sub1-$sub1sha1\n Entering '../sub3'\n+EOF\n+\n+cat >expect <<EOF\n+$pwd/clone-foo1-../sub1-$sub1sha1\n $pwd/clone-foo3-../sub3-$sub3sha1\n EOF\n \n@@ -91,9 +98,10 @@ test_expect_success 'test \"submodule foreach\" from subdirectory' '\n \tmkdir clone/sub &&\n \t(\n \t\tcd clone/sub &&\n-\t\tgit submodule foreach \"echo \\$toplevel-\\$name-\\$sm_path-\\$sha1\" >../../actual\n+\t\tgit submodule foreach \"echo \\$toplevel-\\$name-\\$sm_path-\\$sha1\" >../../actual 2>../../actual2\n \t) &&\n-\ttest_i18ncmp expect actual\n+\ttest_i18ncmp expect actual &&\n+\ttest_i18ncmp expect2 actual2\n '\n \n test_expect_success 'setup nested submodules' '\n@@ -172,7 +180,7 @@ EOF\n test_expect_success 'test messages from \"foreach --recursive\"' '\n \t(\n \t\tcd clone2 &&\n-\t\tgit submodule foreach --recursive \"true\" > ../actual\n+\t\tgit submodule foreach --recursive \"true\" 2>../actual\n \t) &&\n \ttest_i18ncmp expect actual\n '\n@@ -192,7 +200,7 @@ test_expect_success 'test messages from \"foreach --recursive\" from subdirectory'\n \t\tcd clone2 &&\n \t\tmkdir untracked &&\n \t\tcd untracked &&\n-\t\tgit submodule foreach --recursive >../../actual\n+\t\tgit submodule foreach --recursive 2>../../actual\n \t) &&\n \ttest_i18ncmp expect actual\n '\n@@ -210,9 +218,10 @@ EOF\n test_expect_success 'test \"foreach --quiet --recursive\"' '\n \t(\n \t\tcd clone2 &&\n-\t\tgit submodule foreach -q --recursive \"echo \\$name-\\$path\" > ../actual\n+\t\tgit submodule foreach -q --recursive \"echo \\$name-\\$path\" >../actual 2> ../actual2\n \t) &&\n-\ttest_cmp expect actual\n+\ttest_cmp expect actual &&\n+\ttest_must_be_empty actual2\n '\n \n test_expect_success 'use \"update --recursive\" to checkout all submodules' '\n-- \n2.8.0.32.g71f8beb.dirty\n"},{"id":"285012","messageId":"1461976845-18228-9-git-send-email-sbeller@google.com","threadId":"42185","inReplyTo":"1461976845-18228-1-git-send-email-sbeller@google.com","subject":"[PATCH 08/10] submodule update: send messages to stderr","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-30T00:40:43Z","receivedAt":"2016-04-30T00:40:43Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Reroute the output of stdout to stderr as it is just informative\nmessages, not to be consumed by machines.\n\nThis should not regress any scripts that try to parse the\ncurrent output, as the output is already internationalized\nand therefore unstable.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n git-submodule.sh            |  2 +-\n t/t7406-submodule-update.sh | 23 ++++++++++-------------\n 2 files changed, 11 insertions(+), 14 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 80270db..c86c2e5 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -679,7 +679,7 @@ cmd_update()\n \n \t\t\tif (clear_local_git_env; cd \"$sm_path\" && $command \"$sha1\")\n \t\t\tthen\n-\t\t\t\tsay \"$say_msg\"\n+\t\t\t\tsay >&2 \"$say_msg\"\n \t\t\telif test -n \"$must_die_on_failure\"\n \t\t\tthen\n \t\t\t\tdie_with_status 2 \"$die_msg\"\ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 5f27879..1f8faa8 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -106,15 +106,8 @@ rebasingsha1=$(git -C super/rebasing rev-parse HEAD)\n submodulesha1=$(git -C super/submodule rev-parse HEAD)\n pwd=$(pwd)\n \n-cat <<EOF >expect\n-Submodule path '../super': checked out '$supersha1'\n-Submodule path '../super/merging': checked out '$mergingsha1'\n-Submodule path '../super/none': checked out '$nonesha1'\n-Submodule path '../super/rebasing': checked out '$rebasingsha1'\n-Submodule path '../super/submodule': checked out '$submodulesha1'\n-EOF\n-\n cat <<EOF >expect2\n+Submodule path '../super': checked out '$supersha1'\n Submodule 'merging' ($pwd/merging) registered for path '../super/merging'\n Submodule 'none' ($pwd/none) registered for path '../super/none'\n Submodule 'rebasing' ($pwd/rebasing) registered for path '../super/rebasing'\n@@ -127,6 +120,10 @@ Cloning into '$pwd/recursivesuper/super/rebasing'...\n done.\n Cloning into '$pwd/recursivesuper/super/submodule'...\n done.\n+Submodule path '../super/merging': checked out '$mergingsha1'\n+Submodule path '../super/none': checked out '$nonesha1'\n+Submodule path '../super/rebasing': checked out '$rebasingsha1'\n+Submodule path '../super/submodule': checked out '$submodulesha1'\n EOF\n \n test_expect_success 'submodule update --init --recursive from subdirectory' '\n@@ -136,7 +133,7 @@ test_expect_success 'submodule update --init --recursive from subdirectory' '\n \t cd tmp &&\n \t git submodule update --init --recursive ../super >../../actual 2>../../actual2\n \t) &&\n-\ttest_cmp expect actual &&\n+\ttest_must_be_empty actual &&\n \ttest_cmp expect2 actual2\n '\n \n@@ -156,8 +153,8 @@ test_expect_success 'submodule update does not fetch already present commits' '\n \t(cd super &&\n \t  git submodule update > ../actual 2> ../actual.err\n \t) &&\n-\ttest_i18ncmp expected actual &&\n-\t! test -s actual.err\n+\ttest_must_be_empty actual &&\n+\ttest_i18ncmp expected actual.err\n '\n \n test_expect_success 'submodule update should fail due to local changes' '\n@@ -790,7 +787,7 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re\n \trm -rf super_update_r2 &&\n \tgit clone super_update_r super_update_r2 &&\n \t(cd super_update_r2 &&\n-\t git submodule update --init --recursive >actual &&\n+\t git submodule update --init --recursive 2>actual &&\n \t test_i18ngrep \"Submodule path .submodule/subsubmodule.: checked out\" actual &&\n \t (cd submodule/subsubmodule &&\n \t  git log > ../../expected\n@@ -858,7 +855,7 @@ test_expect_success 'submodule update --recursive drops module name before recur\n \t (cd deeper/submodule/subsubmodule &&\n \t  git checkout HEAD^\n \t ) &&\n-\t git submodule update --recursive deeper/submodule >actual &&\n+\t git submodule update --recursive deeper/submodule 2>actual &&\n \t test_i18ngrep \"Submodule path .deeper/submodule/subsubmodule.: checked out\" actual\n \t)\n '\n-- \n2.8.0.32.g71f8beb.dirty\n"},{"id":"285018","messageId":"1461976845-18228-10-git-send-email-sbeller@google.com","threadId":"42185","inReplyTo":"1461976845-18228-1-git-send-email-sbeller@google.com","subject":"[PATCH 09/10] submodule sync: send messages to stderr","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-30T00:40:44Z","receivedAt":"2016-04-30T00:40:44Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Reroute the output of stdout to stderr as it is just informative\nmessages, not to be consumed by machines.\n\nThis should not regress any scripts that try to parse the\ncurrent output, as the output is already internationalized\nand therefore unstable.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n git-submodule.sh          | 2 +-\n t/t7403-submodule-sync.sh | 4 ++--\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex c86c2e5..f075924 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -1095,7 +1095,7 @@ cmd_sync()\n \t\tif git config \"submodule.$name.url\" >/dev/null 2>/dev/null\n \t\tthen\n \t\t\tdisplaypath=$(relative_path \"$prefix$sm_path\")\n-\t\t\tsay \"$(eval_gettext \"Synchronizing submodule url for '\\$displaypath'\")\"\n+\t\t\tsay >&2 \"$(eval_gettext \"Synchronizing submodule url for '\\$displaypath'\")\"\n \t\t\tgit config submodule.\"$name\".url \"$super_config_url\"\n \n \t\t\tif test -e \"$sm_path\"/.git\ndiff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh\nindex 79bc135..93c1dfa 100755\n--- a/t/t7403-submodule-sync.sh\n+++ b/t/t7403-submodule-sync.sh\n@@ -155,7 +155,7 @@ test_expect_success '\"git submodule sync\" should update submodule URLs - subdire\n \t\tgit pull --no-recurse-submodules &&\n \t\tmkdir -p sub &&\n \t\tcd sub &&\n-\t\tgit submodule sync >../../output\n+\t\tgit submodule sync 2>../../output\n \t) &&\n \tgrep \"\\\\.\\\\./submodule\" output &&\n \ttest -d \"$(\n@@ -186,7 +186,7 @@ test_expect_success '\"git submodule sync --recursive\" should update all submodul\n \t\t) &&\n \t\tmkdir -p sub &&\n \t\tcd sub &&\n-\t\tgit submodule sync --recursive >../../output\n+\t\tgit submodule sync --recursive 2>../../output\n \t) &&\n \tgrep \"\\\\.\\\\./submodule/sub-submodule\" output &&\n \ttest -d \"$(\n-- \n2.8.0.32.g71f8beb.dirty\n"},{"id":"285014","messageId":"1461976845-18228-11-git-send-email-sbeller@google.com","threadId":"42185","inReplyTo":"1461976845-18228-1-git-send-email-sbeller@google.com","subject":"[PATCH 10/10] submodule deinit: complain when given a file instead of a submodule","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-30T00:40:45Z","receivedAt":"2016-04-30T00:40:45Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"This also improves performance for listing submodules, because\nS_ISGITLINK is both faster as match_pathspec as well as expected to\nbe true in fewer cases, so putting it first in the condition will speed\nup the loop to compute all submodules.\n\nAs this partially reverts 84ba959bbdf0 (submodule: fix regression for\ndeinit without submodules, 2016-03-22), this also disallows the use\nof `git submodule deinit .` to deinit all submodules, when no\nsubmodules are present. `deinit .` continues to work on repositories,\nwhich have at least one submodule.\n\nCC: Per Cederqvist <cederp@opera.com>\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\n\n> Patch 10 is a controversial thing I'd assume as it breaks existing users.\n> We should take it for the next major release (i.e. 3.0)\n> I just want to put it out here now.\n\n builtin/submodule--helper.c |  6 +++---\n t/t7400-submodule-basic.sh  | 15 ++++++++++++++-\n 2 files changed, 17 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 7f0941d..e41de3e 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -242,9 +242,9 @@ static int module_list_compute(int argc, const char **argv,\n \tfor (i = 0; i < active_nr; i++) {\n \t\tconst struct cache_entry *ce = active_cache[i];\n \n-\t\tif (!match_pathspec(pathspec, ce->name, ce_namelen(ce),\n-\t\t\t\t    0, ps_matched, 1) ||\n-\t\t    !S_ISGITLINK(ce->ce_mode))\n+\t\tif (!S_ISGITLINK(ce->ce_mode) ||\n+\t\t    !match_pathspec(pathspec, ce->name, ce_namelen(ce),\n+\t\t\t\t    0, ps_matched, 1))\n \t\t\tcontinue;\n \n \t\tALLOC_GROW(list->entries, list->nr + 1, list->alloc);\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 53644da..361e6f6 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -915,7 +915,20 @@ test_expect_success 'submodule deinit works on repository without submodules' '\n \t\t>file &&\n \t\tgit add file &&\n \t\tgit commit -m \"repo should not be empty\" &&\n-\t\tgit submodule deinit .\n+\t\tgit submodule deinit\n+\t)\n+'\n+\n+test_expect_success 'submodule deinit refuses to deinit a file' '\n+\ttest_when_finished \"rm -rf newdirectory\" &&\n+\tmkdir newdirectory &&\n+\t(\n+\t\tcd newdirectory &&\n+\t\tgit init &&\n+\t\t>file &&\n+\t\tgit add file &&\n+\t\tgit commit -m \"repo should not be empty\" &&\n+\t\ttest_must_fail git submodule deinit file\n \t)\n '\n \n-- \n2.8.0.32.g71f8beb.dirty\n"},{"id":"285152","messageId":"CAP=KgsStNm7eUWRfzDPje8mAQ2hFCMJ6MpCeF_OgPvir244vgQ@mail.gmail.com","threadId":"42185","inReplyTo":"1461976845-18228-11-git-send-email-sbeller@google.com","subject":"Re: [PATCH 10/10] submodule deinit: complain when given a file instead of a submodule","fromName":"Per Cederqvist","fromEmail":"cederp@opera.com","sentAt":"2016-05-02T08:26:02Z","receivedAt":"2016-05-02T08:26:02Z","isPatch":true,"sender":{"key":"cederp@opera.com","avatar":"https://gravatar.com/avatar/008fe28caedea0ba34042cd5157705267934f4ba7a9b29fb248ae18ec5b3055e?d=mp&s=160"},"body":"After this change, what is the simplest way to programmatically\ndeinit any submodule that may exist, without failing if there are\nnone?\n\n\"git commit\" by default refuses to make an empty commit, but\nit has the --allow-empty option.\n\n\"git rm -r .\" by default fails if there are no files in the repository,\nbut it has the --ignore-unmatch option.\n\nIt makes sense that \"git submodule deinit .\" should fail if there\nare no submodules, but please add support for --ignore-unmatch\nat the same time.\n\n    /ceder\n\n\nOn Sat, Apr 30, 2016 at 2:40 AM, Stefan Beller <sbeller@google.com> wrote:\n> This also improves performance for listing submodules, because\n> S_ISGITLINK is both faster as match_pathspec as well as expected to\n> be true in fewer cases, so putting it first in the condition will speed\n> up the loop to compute all submodules.\n>\n> As this partially reverts 84ba959bbdf0 (submodule: fix regression for\n> deinit without submodules, 2016-03-22), this also disallows the use\n> of `git submodule deinit .` to deinit all submodules, when no\n> submodules are present. `deinit .` continues to work on repositories,\n> which have at least one submodule.\n>\n> CC: Per Cederqvist <cederp@opera.com>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>\n>\n>> Patch 10 is a controversial thing I'd assume as it breaks existing users.\n>> We should take it for the next major release (i.e. 3.0)\n>> I just want to put it out here now.\n>\n>  builtin/submodule--helper.c |  6 +++---\n>  t/t7400-submodule-basic.sh  | 15 ++++++++++++++-\n>  2 files changed, 17 insertions(+), 4 deletions(-)\n>\n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index 7f0941d..e41de3e 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -242,9 +242,9 @@ static int module_list_compute(int argc, const char **argv,\n>         for (i = 0; i < active_nr; i++) {\n>                 const struct cache_entry *ce = active_cache[i];\n>\n> -               if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),\n> -                                   0, ps_matched, 1) ||\n> -                   !S_ISGITLINK(ce->ce_mode))\n> +               if (!S_ISGITLINK(ce->ce_mode) ||\n> +                   !match_pathspec(pathspec, ce->name, ce_namelen(ce),\n> +                                   0, ps_matched, 1))\n>                         continue;\n>\n>                 ALLOC_GROW(list->entries, list->nr + 1, list->alloc);\n> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\n> index 53644da..361e6f6 100755\n> --- a/t/t7400-submodule-basic.sh\n> +++ b/t/t7400-submodule-basic.sh\n> @@ -915,7 +915,20 @@ test_expect_success 'submodule deinit works on repository without submodules' '\n>                 >file &&\n>                 git add file &&\n>                 git commit -m \"repo should not be empty\" &&\n> -               git submodule deinit .\n> +               git submodule deinit\n> +       )\n> +'\n> +\n> +test_expect_success 'submodule deinit refuses to deinit a file' '\n> +       test_when_finished \"rm -rf newdirectory\" &&\n> +       mkdir newdirectory &&\n> +       (\n> +               cd newdirectory &&\n> +               git init &&\n> +               >file &&\n> +               git add file &&\n> +               git commit -m \"repo should not be empty\" &&\n> +               test_must_fail git submodule deinit file\n>         )\n>  '\n>\n> --\n> 2.8.0.32.g71f8beb.dirty\n>\n"},{"id":"285162","messageId":"CAGZ79kZbb=PuTwfagDZETkFEaq-3Fp4Bd7ex03TMixUDLtZtiA@mail.gmail.com","threadId":"42185","inReplyTo":"CAP=KgsStNm7eUWRfzDPje8mAQ2hFCMJ6MpCeF_OgPvir244vgQ@mail.gmail.com","subject":"Re: [PATCH 10/10] submodule deinit: complain when given a file instead of a submodule","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-05-02T16:21:56Z","receivedAt":"2016-05-02T16:21:56Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, May 2, 2016 at 1:26 AM, Per Cederqvist <cederp@opera.com> wrote:\n> After this change, what is the simplest way to programmatically\n> deinit any submodule that may exist, without failing if there are\n> none?\n>\n> \"git commit\" by default refuses to make an empty commit, but\n> it has the --allow-empty option.\n>\n> \"git rm -r .\" by default fails if there are no files in the repository,\n> but it has the --ignore-unmatch option.\n>\n> It makes sense that \"git submodule deinit .\" should fail if there\n> are no submodules, but please add support for --ignore-unmatch\n> at the same time.\n\nOh right. I'll add the --ignore-unmatch option when rerolling this series.\n\nThanks,\nStefan\n\n>\n>     /ceder\n>\n>\n> On Sat, Apr 30, 2016 at 2:40 AM, Stefan Beller <sbeller@google.com> wrote:\n>> This also improves performance for listing submodules, because\n>> S_ISGITLINK is both faster as match_pathspec as well as expected to\n>> be true in fewer cases, so putting it first in the condition will speed\n>> up the loop to compute all submodules.\n>>\n>> As this partially reverts 84ba959bbdf0 (submodule: fix regression for\n>> deinit without submodules, 2016-03-22), this also disallows the use\n>> of `git submodule deinit .` to deinit all submodules, when no\n>> submodules are present. `deinit .` continues to work on repositories,\n>> which have at least one submodule.\n>>\n>> CC: Per Cederqvist <cederp@opera.com>\n>> Signed-off-by: Stefan Beller <sbeller@google.com>\n>> ---\n>>\n>>\n>>> Patch 10 is a controversial thing I'd assume as it breaks existing users.\n>>> We should take it for the next major release (i.e. 3.0)\n>>> I just want to put it out here now.\n>>\n>>  builtin/submodule--helper.c |  6 +++---\n>>  t/t7400-submodule-basic.sh  | 15 ++++++++++++++-\n>>  2 files changed, 17 insertions(+), 4 deletions(-)\n>>\n>> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n>> index 7f0941d..e41de3e 100644\n>> --- a/builtin/submodule--helper.c\n>> +++ b/builtin/submodule--helper.c\n>> @@ -242,9 +242,9 @@ static int module_list_compute(int argc, const char **argv,\n>>         for (i = 0; i < active_nr; i++) {\n>>                 const struct cache_entry *ce = active_cache[i];\n>>\n>> -               if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),\n>> -                                   0, ps_matched, 1) ||\n>> -                   !S_ISGITLINK(ce->ce_mode))\n>> +               if (!S_ISGITLINK(ce->ce_mode) ||\n>> +                   !match_pathspec(pathspec, ce->name, ce_namelen(ce),\n>> +                                   0, ps_matched, 1))\n>>                         continue;\n>>\n>>                 ALLOC_GROW(list->entries, list->nr + 1, list->alloc);\n>> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\n>> index 53644da..361e6f6 100755\n>> --- a/t/t7400-submodule-basic.sh\n>> +++ b/t/t7400-submodule-basic.sh\n>> @@ -915,7 +915,20 @@ test_expect_success 'submodule deinit works on repository without submodules' '\n>>                 >file &&\n>>                 git add file &&\n>>                 git commit -m \"repo should not be empty\" &&\n>> -               git submodule deinit .\n>> +               git submodule deinit\n>> +       )\n>> +'\n>> +\n>> +test_expect_success 'submodule deinit refuses to deinit a file' '\n>> +       test_when_finished \"rm -rf newdirectory\" &&\n>> +       mkdir newdirectory &&\n>> +       (\n>> +               cd newdirectory &&\n>> +               git init &&\n>> +               >file &&\n>> +               git add file &&\n>> +               git commit -m \"repo should not be empty\" &&\n>> +               test_must_fail git submodule deinit file\n>>         )\n>>  '\n>>\n>> --\n>> 2.8.0.32.g71f8beb.dirty\n>>\n"},{"id":"285163","messageId":"CAGZ79kY2hyRgn+oS436Hdr73ajW+Aeg+X-i5BSB41xqyfkz1Mw@mail.gmail.com","threadId":"42185","inReplyTo":"CAGZ79kZbb=PuTwfagDZETkFEaq-3Fp4Bd7ex03TMixUDLtZtiA@mail.gmail.com","subject":"Re: [PATCH 10/10] submodule deinit: complain when given a file instead of a submodule","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-05-02T17:00:32Z","receivedAt":"2016-05-02T17:00:32Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, May 2, 2016 at 9:21 AM, Stefan Beller <sbeller@google.com> wrote:\n> On Mon, May 2, 2016 at 1:26 AM, Per Cederqvist <cederp@opera.com> wrote:\n>> After this change, what is the simplest way to programmatically\n>> deinit any submodule that may exist, without failing if there are\n>> none?\n>>\n>> \"git commit\" by default refuses to make an empty commit, but\n>> it has the --allow-empty option.\n>>\n>> \"git rm -r .\" by default fails if there are no files in the repository,\n>> but it has the --ignore-unmatch option.\n>>\n>> It makes sense that \"git submodule deinit .\" should fail if there\n>> are no submodules, but please add support for --ignore-unmatch\n>> at the same time.\n\nWith this patch series, you can omit the trailing dot, i.e.\n\"git submodule deinit\" works. I just tested that and it works in\nrepositories with no submodules as well as in empty repositories,\nbut I'll add a test for that as well.\n\n>\n> Oh right. I'll add the --ignore-unmatch option when rerolling this series.\n>\n> Thanks,\n> Stefan\n>\n>>\n>>     /ceder\n>>\n>>\n>> On Sat, Apr 30, 2016 at 2:40 AM, Stefan Beller <sbeller@google.com> wrote:\n>>> This also improves performance for listing submodules, because\n>>> S_ISGITLINK is both faster as match_pathspec as well as expected to\n>>> be true in fewer cases, so putting it first in the condition will speed\n>>> up the loop to compute all submodules.\n>>>\n>>> As this partially reverts 84ba959bbdf0 (submodule: fix regression for\n>>> deinit without submodules, 2016-03-22), this also disallows the use\n>>> of `git submodule deinit .` to deinit all submodules, when no\n>>> submodules are present. `deinit .` continues to work on repositories,\n>>> which have at least one submodule.\n>>>\n>>> CC: Per Cederqvist <cederp@opera.com>\n>>> Signed-off-by: Stefan Beller <sbeller@google.com>\n>>> ---\n>>>\n>>>\n>>>> Patch 10 is a controversial thing I'd assume as it breaks existing users.\n>>>> We should take it for the next major release (i.e. 3.0)\n>>>> I just want to put it out here now.\n>>>\n>>>  builtin/submodule--helper.c |  6 +++---\n>>>  t/t7400-submodule-basic.sh  | 15 ++++++++++++++-\n>>>  2 files changed, 17 insertions(+), 4 deletions(-)\n>>>\n>>> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n>>> index 7f0941d..e41de3e 100644\n>>> --- a/builtin/submodule--helper.c\n>>> +++ b/builtin/submodule--helper.c\n>>> @@ -242,9 +242,9 @@ static int module_list_compute(int argc, const char **argv,\n>>>         for (i = 0; i < active_nr; i++) {\n>>>                 const struct cache_entry *ce = active_cache[i];\n>>>\n>>> -               if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),\n>>> -                                   0, ps_matched, 1) ||\n>>> -                   !S_ISGITLINK(ce->ce_mode))\n>>> +               if (!S_ISGITLINK(ce->ce_mode) ||\n>>> +                   !match_pathspec(pathspec, ce->name, ce_namelen(ce),\n>>> +                                   0, ps_matched, 1))\n>>>                         continue;\n>>>\n>>>                 ALLOC_GROW(list->entries, list->nr + 1, list->alloc);\n>>> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\n>>> index 53644da..361e6f6 100755\n>>> --- a/t/t7400-submodule-basic.sh\n>>> +++ b/t/t7400-submodule-basic.sh\n>>> @@ -915,7 +915,20 @@ test_expect_success 'submodule deinit works on repository without submodules' '\n>>>                 >file &&\n>>>                 git add file &&\n>>>                 git commit -m \"repo should not be empty\" &&\n>>> -               git submodule deinit .\n>>> +               git submodule deinit\n>>> +       )\n>>> +'\n>>> +\n>>> +test_expect_success 'submodule deinit refuses to deinit a file' '\n>>> +       test_when_finished \"rm -rf newdirectory\" &&\n>>> +       mkdir newdirectory &&\n>>> +       (\n>>> +               cd newdirectory &&\n>>> +               git init &&\n>>> +               >file &&\n>>> +               git add file &&\n>>> +               git commit -m \"repo should not be empty\" &&\n>>> +               test_must_fail git submodule deinit file\n>>>         )\n>>>  '\n>>>\n>>> --\n>>> 2.8.0.32.g71f8beb.dirty\n>>>\n"},{"id":"285224","messageId":"xmqqy47soxcf.fsf@gitster.mtv.corp.google.com","threadId":"42185","inReplyTo":"1461976845-18228-6-git-send-email-sbeller@google.com","subject":"Re: [PATCH 05/10] submodule add: send messages to stderr","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-02T23:26:40Z","receivedAt":"2016-05-02T23:26:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> Reroute the output of stdout to stderr as it is just informative\n> messages, not to be consumed by machines.\n>\n> This should not regress any scripts that try to parse the\n> current output, as the output is already internationalized\n> and therefore unstable.\n>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n\nSounds sensible.\n\n>  git-submodule.sh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index d689265..f4d500e 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -271,7 +271,7 @@ Use -f if you really want to add it.\" >&2\n>  \t\t\t\techo >&2 \"$(eval_gettext \"use the '--force' option. If the local git directory is not the correct repo\")\"\n>  \t\t\t\tdie \"$(eval_gettext \"or you are unsure what this means choose another name with the '--name' option.\")\"\n>  \t\t\telse\n> -\t\t\t\techo \"$(eval_gettext \"Reactivating local git directory for submodule '\\$sm_name'.\")\"\n> +\t\t\t\techo >&2 \"$(eval_gettext \"Reactivating local git directory for submodule '\\$sm_name'.\")\"\n>  \t\t\tfi\n>  \t\tfi\n>  \t\tgit submodule--helper clone ${GIT_QUIET:+--quiet} --prefix \"$wt_prefix\" --path \"$sm_path\" --name \"$sm_name\" --url \"$realrepo\" \"$reference\" \"$depth\" || exit\n"},{"id":"285225","messageId":"xmqqtwigox9x.fsf@gitster.mtv.corp.google.com","threadId":"42185","inReplyTo":"1461976845-18228-5-git-send-email-sbeller@google.com","subject":"Re: [PATCH 04/10] shell helpers usage: always send help to stderr","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-02T23:28:10Z","receivedAt":"2016-05-02T23:28:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> `git submodule asdf` would trigger displaying the usage of the submodule\n> command on stderr, however `git submodule -h` would display the usage on\n> stdout. Unify displaying help for shell commands on stderr.\n\nThe primary output from \"git cmd --help\" is the usage message.  It\nis debatable why it should go to the standard error output when it\nis the primary thing the user asked for.\n\n\n\n>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>  git-sh-setup.sh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/git-sh-setup.sh b/git-sh-setup.sh\n> index c48139a..5c02446 100644\n> --- a/git-sh-setup.sh\n> +++ b/git-sh-setup.sh\n> @@ -65,7 +65,7 @@ say () {\n>  \n>  if test -n \"$OPTIONS_SPEC\"; then\n>  \tusage() {\n> -\t\t\"$0\" -h\n> +\t\t\"$0\" -h 1>&2\n>  \t\texit 1\n>  \t}\n"},{"id":"285226","messageId":"xmqqpot4ox9d.fsf@gitster.mtv.corp.google.com","threadId":"42185","inReplyTo":"1461976845-18228-7-git-send-email-sbeller@google.com","subject":"Re: [PATCH 06/10] submodule deinit: send messages to stderr","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-02T23:28:30Z","receivedAt":"2016-05-02T23:28:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> Reroute the output of stdout to stderr as it is just informative\n> messages, not to be consumed by machines.\n>\n> This should not regress any scripts that try to parse the\n> current output, as the output is already internationalized\n> and therefore unstable.\n>\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n\nSounds sensible.\n\n>  git-submodule.sh           |  8 ++++----\n>  t/t7400-submodule-basic.sh | 20 ++++++++++----------\n>  2 files changed, 14 insertions(+), 14 deletions(-)\n>\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index f4d500e..3f67f4e 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -452,11 +452,11 @@ cmd_deinit()\n>  \t\t\t\tdie \"$(eval_gettext \"Submodule work tree '\\$displaypath' contains local modifications; use '-f' to discard them\")\"\n>  \t\t\tfi\n>  \t\t\trm -rf \"$sm_path\" &&\n> -\t\t\tsay \"$(eval_gettext \"Cleared directory '\\$displaypath'\")\" ||\n> -\t\t\tsay \"$(eval_gettext \"Could not remove submodule work tree '\\$displaypath'\")\"\n> +\t\t\tsay >&2 \"$(eval_gettext \"Cleared directory '\\$displaypath'\")\" ||\n> +\t\t\tsay >&2 \"$(eval_gettext \"Could not remove submodule work tree '\\$displaypath'\")\"\n>  \t\tfi\n>  \n> -\t\tmkdir \"$sm_path\" || say \"$(eval_gettext \"Could not create empty submodule directory '\\$displaypath'\")\"\n> +\t\tmkdir \"$sm_path\" || say >&2 \"$(eval_gettext \"Could not create empty submodule directory '\\$displaypath'\")\"\n>  \n>  \t\t# Remove the .git/config entries (unless the user already did it)\n>  \t\tif test -n \"$(git config --get-regexp submodule.\"$name\\.\")\"\n> @@ -465,7 +465,7 @@ cmd_deinit()\n>  \t\t\t# the user later decides to init this submodule again\n>  \t\t\turl=$(git config submodule.\"$name\".url)\n>  \t\t\tgit config --remove-section submodule.\"$name\" 2>/dev/null &&\n> -\t\t\tsay \"$(eval_gettext \"Submodule '\\$name' (\\$url) unregistered for path '\\$displaypath'\")\"\n> +\t\t\tsay >&2 \"$(eval_gettext \"Submodule '\\$name' (\\$url) unregistered for path '\\$displaypath'\")\"\n>  \t\tfi\n>  \tdone\n>  }\n> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\n> index a6231f1..53644da 100755\n> --- a/t/t7400-submodule-basic.sh\n> +++ b/t/t7400-submodule-basic.sh\n> @@ -935,7 +935,7 @@ test_expect_success 'submodule deinit from subdirectory' '\n>  \tmkdir -p sub &&\n>  \t(\n>  \t\tcd sub &&\n> -\t\tgit submodule deinit ../init >../output\n> +\t\tgit submodule deinit ../init 2>../output\n>  \t) &&\n>  \tgrep \"\\\\.\\\\./init\" output &&\n>  \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n> @@ -948,7 +948,7 @@ test_expect_success 'submodule deinit . deinits all initialized submodules' '\n>  \tgit submodule update --init &&\n>  \tgit config submodule.example.foo bar &&\n>  \tgit config submodule.example2.frotz nitfol &&\n> -\tgit submodule deinit . >actual &&\n> +\tgit submodule deinit . 2>actual &&\n>  \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n>  \ttest -z \"$(git config --get-regexp \"submodule\\.example2\\.\")\" &&\n>  \ttest_i18ngrep \"Cleared directory .init\" actual &&\n> @@ -959,7 +959,7 @@ test_expect_success 'submodule deinit . deinits all initialized submodules' '\n>  test_expect_success 'submodule deinit deinits a submodule when its work tree is missing or empty' '\n>  \tgit submodule update --init &&\n>  \trm -rf init example2/* example2/.git &&\n> -\tgit submodule deinit init example2 >actual &&\n> +\tgit submodule deinit init example2 2>actual &&\n>  \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n>  \ttest -z \"$(git config --get-regexp \"submodule\\.example2\\.\")\" &&\n>  \ttest_i18ngrep ! \"Cleared directory .init\" actual &&\n> @@ -973,7 +973,7 @@ test_expect_success 'submodule deinit fails when the submodule contains modifica\n>  \ttest_must_fail git submodule deinit init &&\n>  \ttest -n \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n>  \ttest -f example2/.git &&\n> -\tgit submodule deinit -f init >actual &&\n> +\tgit submodule deinit -f init 2>actual &&\n>  \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n>  \ttest_i18ngrep \"Cleared directory .init\" actual &&\n>  \trmdir init\n> @@ -985,7 +985,7 @@ test_expect_success 'submodule deinit fails when the submodule contains untracke\n>  \ttest_must_fail git submodule deinit init &&\n>  \ttest -n \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n>  \ttest -f example2/.git &&\n> -\tgit submodule deinit -f init >actual &&\n> +\tgit submodule deinit -f init 2>actual &&\n>  \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n>  \ttest_i18ngrep \"Cleared directory .init\" actual &&\n>  \trmdir init\n> @@ -1000,7 +1000,7 @@ test_expect_success 'submodule deinit fails when the submodule HEAD does not mat\n>  \ttest_must_fail git submodule deinit init &&\n>  \ttest -n \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n>  \ttest -f example2/.git &&\n> -\tgit submodule deinit -f init >actual &&\n> +\tgit submodule deinit -f init 2>actual &&\n>  \ttest -z \"$(git config --get-regexp \"submodule\\.example\\.\")\" &&\n>  \ttest_i18ngrep \"Cleared directory .init\" actual &&\n>  \trmdir init\n> @@ -1008,17 +1008,17 @@ test_expect_success 'submodule deinit fails when the submodule HEAD does not mat\n>  \n>  test_expect_success 'submodule deinit is silent when used on an uninitialized submodule' '\n>  \tgit submodule update --init &&\n> -\tgit submodule deinit init >actual &&\n> +\tgit submodule deinit init 2>actual &&\n>  \ttest_i18ngrep \"Submodule .example. (.*) unregistered for path .init\" actual &&\n>  \ttest_i18ngrep \"Cleared directory .init\" actual &&\n> -\tgit submodule deinit init >actual &&\n> +\tgit submodule deinit init 2>actual &&\n>  \ttest_i18ngrep ! \"Submodule .example. (.*) unregistered for path .init\" actual &&\n>  \ttest_i18ngrep \"Cleared directory .init\" actual &&\n> -\tgit submodule deinit . >actual &&\n> +\tgit submodule deinit . 2>actual &&\n>  \ttest_i18ngrep ! \"Submodule .example. (.*) unregistered for path .init\" actual &&\n>  \ttest_i18ngrep \"Submodule .example2. (.*) unregistered for path .example2\" actual &&\n>  \ttest_i18ngrep \"Cleared directory .init\" actual &&\n> -\tgit submodule deinit . >actual &&\n> +\tgit submodule deinit . 2>actual &&\n>  \ttest_i18ngrep ! \"Submodule .example. (.*) unregistered for path .init\" actual &&\n>  \ttest_i18ngrep ! \"Submodule .example2. (.*) unregistered for path .example2\" actual &&\n>  \ttest_i18ngrep \"Cleared directory .init\" actual &&\n"},{"id":"285227","messageId":"CAGZ79ka7uPxLKVU7Dn-4yHyN1BMgeG33_7LJDShF3UVjrT2fgQ@mail.gmail.com","threadId":"42185","inReplyTo":"xmqqtwigox9x.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 04/10] shell helpers usage: always send help to stderr","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-05-02T23:44:41Z","receivedAt":"2016-05-02T23:44:41Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, May 2, 2016 at 4:28 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>> `git submodule asdf` would trigger displaying the usage of the submodule\n>> command on stderr, however `git submodule -h` would display the usage on\n>> stdout. Unify displaying help for shell commands on stderr.\n>\n> The primary output from \"git cmd --help\" is the usage message.  It\n> is debatable why it should go to the standard error output when it\n> is the primary thing the user asked for.\n\nI had written some lengthy arguments, but when I wanted to back up\nwith data and facts, the first search result[1] convinced me this is\na bad patch as when a user asks for help specifically, they want it\nto easily be piped, i.e.\n\n    git --help |grep pull\n\ninstead of\n\n    git --help 2>&1 |grep pull\n\nSo I'll drop this patch.\nThanks,\nStefan\n\n[1] http://www.jstorimer.com/blogs/workingwithcode/7766119-when-to-use-stderr-instead-of-stdout\n\n>\n>\n>\n>>\n>> Signed-off-by: Stefan Beller <sbeller@google.com>\n>> ---\n>>  git-sh-setup.sh | 2 +-\n>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> diff --git a/git-sh-setup.sh b/git-sh-setup.sh\n>> index c48139a..5c02446 100644\n>> --- a/git-sh-setup.sh\n>> +++ b/git-sh-setup.sh\n>> @@ -65,7 +65,7 @@ say () {\n>>\n>>  if test -n \"$OPTIONS_SPEC\"; then\n>>       usage() {\n>> -             \"$0\" -h\n>> +             \"$0\" -h 1>&2\n>>               exit 1\n>>       }\n"},{"id":"285236","messageId":"xmqqlh3sotoh.fsf@gitster.mtv.corp.google.com","threadId":"42185","inReplyTo":"CAGZ79ka7uPxLKVU7Dn-4yHyN1BMgeG33_7LJDShF3UVjrT2fgQ@mail.gmail.com","subject":"Re: [PATCH 04/10] shell helpers usage: always send help to stderr","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-03T00:45:50Z","receivedAt":"2016-05-03T00:45:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n>     git --help |grep pull\n>\n> instead of\n>\n>     git --help 2>&1 |grep pull\n\nNot just that.  It makes me sad that it is unpredictable which\nstream a project happens to have chosen to send its help text and I\nend up almost always doing\n\n    random-command --help 2>&1 | less\n"},{"id":"285237","messageId":"CAPc5daXuMmuCx8q5pbo2RWcTYazCo+agLB6tspMdNZCh-n2HpQ@mail.gmail.com","threadId":"42185","inReplyTo":"xmqqlh3sotoh.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 04/10] shell helpers usage: always send help to stderr","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-05-03T01:17:33Z","receivedAt":"2016-05-03T01:17:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"It also is somewhat sad that you needed to refer to a random blog you\nfound on the Internet whose punch line was essentially what I already\nsaid before you finally decide to listen to me X-<. I somehow expected\nthat over the years you worked with me you learned I had a reasonable\ntaste in designing these things...\n\nOn Mon, May 2, 2016 at 5:45 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>>     git --help |grep pull\n>>\n>> instead of\n>>\n>>     git --help 2>&1 |grep pull\n>\n> Not just that.  It makes me sad that it is unpredictable which\n> stream a project happens to have chosen to send its help text and I\n> end up almost always doing\n>\n>     random-command --help 2>&1 | less\n>\n"}]}