Stefan Beller <sbel...@google.com> writes:

> * squashed the fixes from Johannes Sixt to unbreak Windows tests.
>   (I had encoding issues; so I manually integrated the changes)
> * fixed memleaks
> * the base to apply did not change (ee30f17805f51d37 Merge branch
> 'sb/submodule-path-misc-bugs' into sb/submodule-init)
>
> Thanks,
> Stefan

Queued.  I read it twice and I think this is ready for 'next'.

Comments from others?

>
> diff to current origin/sb/submodule-init:
>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index ad3cba6..b6d4f27 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -309,8 +309,7 @@ static void init_submodule(const char *path, const char 
> *prefix, int quiet)
>  {
>       const struct submodule *sub;
>       struct strbuf sb = STRBUF_INIT;
> -     const char *upd = NULL;
> -     char *url = NULL, *displaypath;
> +     char *upd = NULL, *url = NULL, *displaypath;
>  
>       /* Only loads from .gitmodules, no overlay with .git/config */
>       gitmodules_config();
> @@ -340,7 +339,7 @@ static void init_submodule(const char *path, const char 
> *prefix, int quiet)
>               /* Possibly a url relative to parent */
>               if (starts_with_dot_dot_slash(url) ||
>                   starts_with_dot_slash(url)) {
> -                     char *remoteurl;
> +                     char *remoteurl, *relurl;
>                       char *remote = get_default_remote();
>                       struct strbuf remotesb = STRBUF_INIT;
>                       strbuf_addf(&remotesb, "remote.%s.url", remote);
> @@ -352,9 +351,11 @@ static void init_submodule(const char *path, const char 
> *prefix, int quiet)
>                                * authoritative upstream
>                                */
>                               remoteurl = xgetcwd();
> -                     url = relative_url(remoteurl, url, NULL);
> +                     relurl = relative_url(remoteurl, url, NULL);
>                       strbuf_release(&remotesb);
>                       free(remoteurl);
> +                     free(url);
> +                     url = relurl;
>               }
>  
>               if (git_config_set_gently(sb.buf, url))
> @@ -368,14 +369,14 @@ static void init_submodule(const char *path, const char 
> *prefix, int quiet)
>       /* 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) &&
> +     if (git_config_get_string(sb.buf, &upd) &&
>           sub->update_strategy.type != SM_UPDATE_UNSPECIFIED) {
>               if (sub->update_strategy.type == SM_UPDATE_COMMAND) {
>                       fprintf(stderr, _("warning: command update mode 
> suggested for submodule '%s'\n"),
>                               sub->name);
> -                     upd = "none";
> +                     upd = xstrdup("none");
>               } else
> -                     upd = 
> submodule_strategy_to_string(&sub->update_strategy);
> +                     upd = 
> xstrdup(submodule_strategy_to_string(&sub->update_strategy));
>  
>               if (git_config_set_gently(sb.buf, upd))
>                       die(_("Failed to register update mode for submodule 
> path '%s'"), displaypath);
> @@ -383,6 +384,7 @@ static void init_submodule(const char *path, const char 
> *prefix, int quiet)
>       strbuf_release(&sb);
>       free(displaypath);
>       free(url);
> +     free(upd);
>  }
>  
>  static int module_init(int argc, const char **argv, const char *prefix)
> diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
> index 2e62548..bf2deee 100755
> --- a/t/t0060-path-utils.sh
> +++ b/t/t0060-path-utils.sh
> @@ -305,13 +305,16 @@ test_git_path GIT_COMMON_DIR=bar config                 
>   bar/config
>  test_git_path GIT_COMMON_DIR=bar packed-refs              bar/packed-refs
>  test_git_path GIT_COMMON_DIR=bar shallow                  bar/shallow
>  
> +# In the tests below, the distinction between $PWD and $(pwd) is important:
> +# on Windows, $PWD is POSIX style (/c/foo), $(pwd) has drive letter (c:/foo).
> +
>  test_submodule_relative_url "../" "../foo" "../submodule" "../../submodule"
>  test_submodule_relative_url "../" "../foo/bar" "../submodule" 
> "../../foo/submodule"
>  test_submodule_relative_url "../" "../foo/submodule" "../submodule" 
> "../../foo/submodule"
>  test_submodule_relative_url "../" "./foo" "../submodule" "../submodule"
>  test_submodule_relative_url "../" "./foo/bar" "../submodule" 
> "../foo/submodule"
>  test_submodule_relative_url "../../../" "../foo/bar" "../sub/a/b/c" 
> "../../../../foo/sub/a/b/c"
> -test_submodule_relative_url "../" "$PWD/addtest" "../repo" "$PWD/repo"
> +test_submodule_relative_url "../" "$PWD/addtest" "../repo" "$(pwd)/repo"
>  test_submodule_relative_url "../" "foo/bar" "../submodule" "../foo/submodule"
>  test_submodule_relative_url "../" "foo" "../submodule" "../submodule"
>  
> @@ -322,16 +325,16 @@ test_submodule_relative_url "(null)" "../foo" 
> "../submodule" "../submodule"
>  test_submodule_relative_url "(null)" "./foo/bar" "../submodule" 
> "foo/submodule"
>  test_submodule_relative_url "(null)" "./foo" "../submodule" "submodule"
>  test_submodule_relative_url "(null)" "//somewhere else/repo" "../subrepo" 
> "//somewhere else/subrepo"
> -test_submodule_relative_url "(null)" "$PWD/subsuper_update_r" 
> "../subsubsuper_update_r" "$PWD/subsubsuper_update_r"
> -test_submodule_relative_url "(null)" "$PWD/super_update_r2" 
> "../subsuper_update_r" "$PWD/subsuper_update_r"
> -test_submodule_relative_url "(null)" "$PWD/." "../." "$PWD/."
> -test_submodule_relative_url "(null)" "$PWD" "./." "$PWD/."
> -test_submodule_relative_url "(null)" "$PWD/addtest" "../repo" "$PWD/repo"
> -test_submodule_relative_url "(null)" "$PWD" "./å äö" "$PWD/å äö"
> -test_submodule_relative_url "(null)" "$PWD/." "../submodule" "$PWD/submodule"
> -test_submodule_relative_url "(null)" "$PWD/submodule" "../submodule" 
> "$PWD/submodule"
> -test_submodule_relative_url "(null)" "$PWD/home2/../remote" "../bundle1" 
> "$PWD/home2/../bundle1"
> -test_submodule_relative_url "(null)" "$PWD/submodule_update_repo" "./." 
> "$PWD/submodule_update_repo/."
> +test_submodule_relative_url "(null)" "$PWD/subsuper_update_r" 
> "../subsubsuper_update_r" "$(pwd)/subsubsuper_update_r"
> +test_submodule_relative_url "(null)" "$PWD/super_update_r2" 
> "../subsuper_update_r" "$(pwd)/subsuper_update_r"
> +test_submodule_relative_url "(null)" "$PWD/." "../." "$(pwd)/."
> +test_submodule_relative_url "(null)" "$PWD" "./." "$(pwd)/."
> +test_submodule_relative_url "(null)" "$PWD/addtest" "../repo" "$(pwd)/repo"
> +test_submodule_relative_url "(null)" "$PWD" "./å äö" "$(pwd)/å äö"
> +test_submodule_relative_url "(null)" "$PWD/." "../submodule" 
> "$(pwd)/submodule"
> +test_submodule_relative_url "(null)" "$PWD/submodule" "../submodule" 
> "$(pwd)/submodule"
> +test_submodule_relative_url "(null)" "$PWD/home2/../remote" "../bundle1" 
> "$(pwd)/home2/../bundle1"
> +test_submodule_relative_url "(null)" "$PWD/submodule_update_repo" "./." 
> "$(pwd)/submodule_update_repo/."
>  test_submodule_relative_url "(null)" "file:///tmp/repo" "../subrepo" 
> "file:///tmp/subrepo"
>  test_submodule_relative_url "(null)" "foo/bar" "../submodule" "foo/submodule"
>  test_submodule_relative_url "(null)" "foo" "../submodule" "submodule"
>
>
> Stefan Beller (2):
>   submodule: port resolve_relative_url from shell to C
>   submodule: port init from shell to C
>
>  builtin/submodule--helper.c | 324 
> +++++++++++++++++++++++++++++++++++++++++++-
>  git-submodule.sh            | 127 +----------------
>  submodule.c                 |  21 +++
>  submodule.h                 |   1 +
>  t/t0060-path-utils.sh       |  46 +++++++
>  5 files changed, 397 insertions(+), 122 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to