From: Junio C Hamano Date: Fri, 22 Apr 2016 22:45:03 +0000 (-0700) Subject: Merge branch 'sb/submodule-helper-clone-regression-fix' X-Git-Tag: v2.9.0-rc0~112 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/deef3cdc08eb16354d16da0813585d60d5f34412 Merge branch 'sb/submodule-helper-clone-regression-fix' A partial rewrite of "git submodule" in the 2.7 timeframe changed the way the gitdir: pointer in the submodules point at the real repository location to use absolute paths by accident. This has been corrected. * sb/submodule-helper-clone-regression-fix: submodule--helper, module_clone: catch fprintf failure submodule--helper: do not borrow absolute_path() result for too long submodule--helper, module_clone: always operate on absolute paths submodule--helper clone: create the submodule path just once submodule--helper: fix potential NULL-dereference recursive submodules: test for relative paths --- deef3cdc08eb16354d16da0813585d60d5f34412 diff --cc builtin/submodule--helper.c index d36e8a0ec4,b3a60f56c3..3bd6883eff --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@@ -237,12 -194,18 +237,19 @@@ static int module_clone(int argc, cons argc = parse_options(argc, argv, prefix, module_clone_options, git_submodule_helper_usage, 0); - if (argc || !url || !path) - if (!path || !*path) - die(_("submodule--helper: unspecified or empty --path")); ++ if (argc || !url || !path || !*path) + usage_with_options(git_submodule_helper_usage, + module_clone_options); strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name); - sm_gitdir = strbuf_detach(&sb, NULL); + sm_gitdir = xstrdup(absolute_path(sb.buf)); + strbuf_reset(&sb); + + if (!is_absolute_path(path)) { + strbuf_addf(&sb, "%s/%s", get_git_work_tree(), path); + path = strbuf_detach(&sb, NULL); + } else + path = xstrdup(path); if (!file_exists(sm_gitdir)) { if (safe_create_leading_directories_const(sm_gitdir) < 0)