{"thread":{"id":"42502","subject":"[PATCH] submodule--helper: offer a consistent API","startedAt":"2016-05-31T23:59:33Z","lastAt":"2016-05-31T23:59:33Z","messageCount":1,"participants":["Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"287958","messageId":"20160531235933.3854-1-sbeller@google.com","threadId":"42502","inReplyTo":null,"subject":"[PATCH] submodule--helper: offer a consistent API","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-05-31T23:59:33Z","receivedAt":"2016-05-31T23:59:33Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"In 48308681 (2016-02-29, git submodule update: have a dedicated helper\nfor cloning), the helper communicated errors back only via exit code,\nand dance with printing '#unmatched' in case of error was left to\ngit-submodule.sh as it uses the output of the helper and pipes it into\nshell commands. This change makes the helper consistent by never\nprinting '#unmatched' in the helper but always handling these piping\nissues in the actual shell script.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\nI think this applies on any of the recent submodule branches;\ncertainly on master (Git 2.9-rc1).\n\nThanks,\nStefan\n\n builtin/submodule--helper.c |  4 +---\n git-submodule.sh            | 20 ++++++++++++++++----\n 2 files changed, 17 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex ca33408..b1ebee2 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -287,10 +287,8 @@ static int module_list(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, module_list_options,\n \t\t\t     git_submodule_helper_usage, 0);\n \n-\tif (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0) {\n-\t\tprintf(\"#unmatched\\n\");\n+\tif (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)\n \t\treturn 1;\n-\t}\n \n \tfor (i = 0; i < list.nr; i++) {\n \t\tconst struct cache_entry *ce = list.entries[i];\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 42e0e9f..0515019 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -345,7 +345,10 @@ cmd_foreach()\n \t# command in the subshell (and a recursive call to this function)\n \texec 3<&0\n \n-\tgit submodule--helper list --prefix \"$wt_prefix\"|\n+\t{\n+\t\tgit submodule--helper list --prefix \"$wt_prefix\" ||\n+\t\techo \"#unmatched\"\n+\t} |\n \twhile read mode sha1 stage sm_path\n \tdo\n \t\tdie_if_unmatched \"$mode\"\n@@ -453,7 +456,10 @@ cmd_deinit()\n \t\tdie \"$(eval_gettext \"Use '--all' if you really want to deinitialize all submodules\")\"\n \tfi\n \n-\tgit submodule--helper list --prefix \"$wt_prefix\" \"$@\" |\n+\t{\n+\t\tgit submodule--helper list --prefix \"$wt_prefix\" \"$@\" ||\n+\t\techo \"#unmatched\"\n+\t} |\n \twhile read mode sha1 stage sm_path\n \tdo\n \t\tdie_if_unmatched \"$mode\"\n@@ -1020,7 +1026,10 @@ cmd_status()\n \t\tshift\n \tdone\n \n-\tgit submodule--helper list --prefix \"$wt_prefix\" \"$@\" |\n+\t{\n+\t\tgit submodule--helper list --prefix \"$wt_prefix\" \"$@\" ||\n+\t\techo \"#unmatched\"\n+\t} |\n \twhile read mode sha1 stage sm_path\n \tdo\n \t\tdie_if_unmatched \"$mode\"\n@@ -1098,7 +1107,10 @@ cmd_sync()\n \t\tesac\n \tdone\n \tcd_to_toplevel\n-\tgit submodule--helper list --prefix \"$wt_prefix\" \"$@\" |\n+\t{\n+\t\tgit submodule--helper list --prefix \"$wt_prefix\" \"$@\" ||\n+\t\techo \"#unmatched\"\n+\t} |\n \twhile read mode sha1 stage sm_path\n \tdo\n \t\tdie_if_unmatched \"$mode\"\n-- \n2.9.0.rc0.2.g145fc64\n"}]}