Port `git submodule init` from shell to C
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest2 patches 5 repliesIn review
- v32 patches 4 repliesSuperseded
- v22 patches 2 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 2 patches | 1 reply | Superseded |
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | submodule: port resolve_relative_url from shell to Cbuiltin/ git-submodule.sh t/ | +253 | 2 replies | |
| 2/2 | submodule: port init from shell to Cbuiltin/ git-submodule.sh | +111 | 2 replies | |
| 2/2 | submodule: port init from shell to Cbuiltin/ git-submodule.sh | +115 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.
Cover letter [PATCHv4 0/2] Port `git submodule init` from shell to C
Hi,
I looked at this patch series again and fixed all memory leaks as found by coverity scan.
This applies on top of sb/submodule-parallel-update
Thanks,
Stefan
Interdiff to v3:
builtin/submodule--helper.c +13 -7
@@ -35,7 +35,7 @@ static char *get_default_remote(void)if (git_config_get_string (sb.buf, &dest)) ret =xstrdup ("origin" );else - ret =xstrdup (dest); + ret = dest;strbuf_release (&sb);return ret;
@@ -188,6 +188,7 @@ static int resolve_relative_url(int argc, const char **argv, const char *prefix) res =relative_url (remoteurl, url, up_path);puts (res);free (res); +free (remoteurl);return 0 ; }
@@ -209,6 +210,7 @@ static int resolve_relative_url_test(int argc, const char **argv, const char *pr res =relative_url (remoteurl, url, up_path);puts (res);free (res); +free (remoteurl);return 0 ; }
@@ -222,8 +224,9 @@ static void init_submodule(const char *path, const char *prefix, int quiet)const struct submodule *sub;struct strbuf sb =STRBUF_INIT ;char *url =NULL ; -const char *upd =NULL ; -const char *displaypath =relative_path (xgetcwd (), prefix, &sb); +char *upd =NULL ; +char *cwd =xgetcwd (); +const char *displaypath =relative_path (cwd, prefix, &sb);/* Only loads from .gitmodules, no overlay with .git/config */ gitmodules_config ();
@@ -261,6 +264,7 @@ static void init_submodule(const char *path, const char *prefix, int quiet) remoteurl =xgetcwd (); url =relative_url (remoteurl, url,NULL );strbuf_release (&remotesb); +free (remoteurl); }if (git_config_set (sb.buf, url))
@@ -269,26 +273,27 @@ static void init_submodule(const char *path, const char *prefix, int quiet)if (!quiet)printf (_ ("Submodule '%s' (%s) registered for path '%s'\n" ), sub->name, url, displaypath); -free (url); }/* Copy "update" setting when it is not set yet */ strbuf_reset (&sb);strbuf_addf (&sb,"submodule.%s.update" , sub->name); -if (git_config_get_string_const (sb.buf, &upd) && sub->update) { - upd = sub->update; +if (git_config_get_string (sb.buf, &upd) && sub->update) { + upd =xstrdup (sub->update);if (strcmp (sub->update,"checkout" ) &&strcmp (sub->update,"rebase" ) &&strcmp (sub->update,"merge" ) &&strcmp (sub->update,"none" )) {fprintf (stderr,_ ("warning: unknown update mode '%s' suggested for submodule '%s'\n" ), upd, sub->name); - upd ="none" ; + upd =xstrdup ("none" ); }if (git_config_set (sb.buf, upd))die (_ ("Failed to register update mode for submodule path '%s'" ), displaypath); }strbuf_release (&sb); +free (cwd); +free (upd); +free (url); }
static int module_init(int argc, const char **argv, const char *prefix)
Stefan Beller (2):
submodule: port resolve_relative_url from shell to C
submodule: port init from shell to C
builtin/submodule--helper.c | 326 +++++++++++++++++++++++++++++++++++++++++++- git-submodule.sh | 118 +--------------- t/t0060-path-utils.sh | 42 ++++++ 3 files changed, 366 insertions(+), 120 deletions(-)
Signature · 1 line
2.7.0.rc0.42.ge5f5e2d