git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv2 0/2] Port `git submodule init` from shell to C

From
Stefan Beller <sbeller@google.com>
Date
Jan 20, 2016, 02:03 UTC
Message-ID
<1453255396-31942-1-git-send-email-sbeller@google.com>
In-Reply-To
<xmqqa8o188i0.fsf@gitster.mtv.corp.google.com>

This replaces sb/submodule-init. As I was crafting another series on top of this series I noticed a two bugs, so I am resending it fixed.

* honor the quiet setting
* print to stderr instead of stdout. (In the next series we want to
  call init_submodule from within update_clone whose stdout is piped into
  git-submodule.sh, so stderr is the only way to talk to the user)

Thanks, Stefan

The interdiff:
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index c7bd38a..fecc9aa 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -226,7 +226,7 @@ static int git_submodule_config(const char *var, const char *value, void *cb)
        return parse_submodule_config_option(var, value);
 }
 
-static void init_submodule(const char *path, const char *prefix)
+static void init_submodule(const char *path, const char *prefix, int quiet)
 {
        const struct submodule *sub;
        struct strbuf sb = STRBUF_INIT;
@@ -275,9 +275,9 @@ static void init_submodule(const char *path, const char *prefix)
                if (git_config_set(sb.buf, url))
                        die(_("Failed to register url for submodule path '%s'"),
                            displaypath);
-
-               printf(_("Submodule '%s' (%s) registered for path '%s'\n"),
-                       sub->name, url, displaypath);
+               if (!quiet)
+                       fprintf(stderr, _("Submodule '%s' (%s) registered for path '%s'\n"),
+                               sub->name, url, displaypath);
                free(url);
        }
 
@@ -325,7 +325,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
                die(_("Pass at least one submodule"));
 
        for (i = 0; i < argc; i++)
-               init_submodule(argv[i], prefix);
+               init_submodule(argv[i], prefix, quiet);
 
        return 0;
 }


Stefan Beller (2):
  submodule: port resolve_relative_url from shell to C
  submodule: port init from shell to C

 builtin/submodule--helper.c | 330 +++++++++++++++++++++++++++++++++++++++++++-
 git-submodule.sh            | 118 +---------------
 t/t0060-path-utils.sh       |  42 ++++++
 3 files changed, 370 insertions(+), 120 deletions(-)
-- 
2.7.0.rc0.44.g6033384.dirty
Previous: Junio C HamanoNext: Stefan Beller
Message 5 of 16 in “Port `git submodule init` from shell to C”
  1. 0/2 Port `git submodule init` from shell to CStefan Beller, Jan 15, 2016
  2. 1/2 submodule: Port resolve_relative_url from shell to CStefan Beller, Jan 15, 2016
  3. 2/2 submodule: Port init from shell to CStefan Beller, Jan 15, 2016
  4. Junio C HamanoJan 19, 2016
  5. 0/2 Port `git submodule init` from shell to CStefan Beller, Jan 20, 2016
  6. 1/2 submodule: port resolve_relative_url from shell to CStefan Beller, Jan 20, 2016
  7. Johannes SixtJan 22, 2016
  8. Stefan BellerJan 22, 2016
  9. 2/2 submodule: port init from shell to CStefan Beller, Jan 20, 2016
  10. 2/2 submodule: port init from shell to CStefan Beller, Jan 20, 2016
  11. Junio C HamanoJan 20, 2016
  12. Stefan BellerJan 20, 2016
  13. Junio C HamanoJan 20, 2016
  14. 2/2 submodule: port init from shell to CStefan Beller, Jan 21, 2016
  15. Junio C HamanoJan 22, 2016
  16. Stefan BellerJan 22, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.