summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/submodule--helper.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 60165a8..6300897 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1568,12 +1568,11 @@ static int clone_submodule(struct module_clone_data *clone_data)
sm_gitdir = absolute_pathdup(sb.buf);
strbuf_reset(&sb);
- if (!is_absolute_path(clone_data->path)) {
- strbuf_addf(&sb, "%s/%s", get_git_work_tree(), clone_data->path);
- clone_data->path = strbuf_detach(&sb, NULL);
- } else {
+ if (!is_absolute_path(clone_data->path))
+ clone_data->path = xstrfmt("%s/%s", get_git_work_tree(),
+ clone_data->path);
+ else
clone_data->path = xstrdup(clone_data->path);
- }
if (validate_submodule_git_dir(sm_gitdir, clone_data->name) < 0)
die(_("refusing to create/use '%s' in another submodule's "
@@ -1625,14 +1624,16 @@ static int clone_submodule(struct module_clone_data *clone_data)
die(_("clone of '%s' into submodule path '%s' failed"),
clone_data->url, clone_data->path);
} else {
+ char *path;
+
if (clone_data->require_init && !access(clone_data->path, X_OK) &&
!is_empty_dir(clone_data->path))
die(_("directory not empty: '%s'"), clone_data->path);
if (safe_create_leading_directories_const(clone_data->path) < 0)
die(_("could not create directory '%s'"), clone_data->path);
- strbuf_addf(&sb, "%s/index", sm_gitdir);
- unlink_or_warn(sb.buf);
- strbuf_reset(&sb);
+ path = xstrfmt("%s/index", sm_gitdir);
+ unlink_or_warn(path);
+ free(path);
}
connect_work_tree_and_git_dir(clone_data->path, sm_gitdir, 0);