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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]