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

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

From
Stefan Beller <sbeller@google.com>
Date
Jan 22, 2016, 23:32 UTC
Message-ID
<1453505536-14895-1-git-send-email-sbeller@google.com>
In-Reply-To
<xmqqoacdtfh3.fsf@gitster.mtv.corp.google.com>

This applies on top of sb/submodule-parallel-update, replacing sb/submodule-init.

Fixes:
 * a more faithful conversion by staying on stdout (We switch to stderr later
   in another series)
 * use the existing find_last_dir_sep instead of reinventing the wheel.
Stefan Beller (2):
  submodule: port resolve_relative_url from shell to C
  submodule: port init from shell to C
 builtin/submodule--helper.c | 321 +++++++++++++++++++++++++++++++++++++++++++-
 git-submodule.sh            | 118 +---------------
 t/t0060-path-utils.sh       |  42 ++++++
 3 files changed, 361 insertions(+), 120 deletions(-)
Interdiff to  origin/sb/submodule-init (committed 2016-01-20 12:55:30)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 4684f16..c9b0c05 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -51,21 +51,12 @@ static int starts_with_dot_dot_slash(const char *str)
        return str[0] == '.' && str[1] == '.' && is_dir_sep(str[2]);
 }
 
-static char *last_dir_separator(char *str)
-{
-       char *p = str + strlen(str);
-       while (p-- > str)
-               if (is_dir_sep(*p))
-                       return p;
-       return NULL;
-}
-
 /*
  * Returns 1 if it was the last chop before ':'.
  */
 static int chop_last_dir(char **remoteurl, int is_relative)
 {
-       char *rfind = last_dir_separator(*remoteurl);
+       char *rfind = find_last_dir_sep(*remoteurl);
        if (rfind) {
                *rfind = '\0';
                return 0;
@@ -232,7 +223,7 @@ static void init_submodule(const char *path, const char *prefix, int quiet)
        struct strbuf sb = STRBUF_INIT;
        char *url = NULL;
        const char *upd = NULL;
-       const char *displaypath = relative_path(xgetcwd(), prefix, &sb);;
+       const char *displaypath = relative_path(xgetcwd(), prefix, &sb);
 
        /* Only loads from .gitmodules, no overlay with .git/config */
        gitmodules_config();
@@ -276,7 +267,7 @@ static void init_submodule(const char *path, const char *prefix, int quiet)
                        die(_("Failed to register url for submodule path '%s'"),
                            displaypath);
                if (!quiet)
-                       fprintf(stderr, _("Submodule '%s' (%s) registered for path '%s'\n"),
+                       printf(_("Submodule '%s' (%s) registered for path '%s'\n"),
                                sub->name, url, displaypath);
                free(url);
        }
-- 
2.7.0.rc0.45.g0dba895.dirty
Next: Stefan Beller
Message 1 of 10 in “[PATCHv3 0/2] Port `git submodule init` from shell to C”
  1. Stefan BellerJan 22, 2016
  2. 1/2 submodule: port resolve_relative_url from shell to CStefan Beller, Jan 22, 2016
  3. 2/2 submodule: port init from shell to CStefan Beller, Jan 22, 2016
  4. Junio C HamanoJan 25, 2016
  5. 0/2 Port `git submodule init` from shell to CStefan Beller, Jan 28, 2016
  6. 1/2 submodule: port resolve_relative_url from shell to CStefan Beller, Jan 28, 2016
  7. Junio C HamanoJan 28, 2016
  8. Stefan BellerJan 28, 2016
  9. 2/2 submodule: port init from shell to CStefan Beller, Jan 28, 2016
  10. Duy NguyenFeb 27, 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.