submodule--helper: die on config error when cloning module
authorPatrick Steinhardt <ps@pks.im>
Mon, 22 Feb 2016 11:23:27 +0000 (12:23 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Feb 2016 18:23:52 +0000 (10:23 -0800)
When setting the 'core.worktree' option for a newly cloned
submodule we ignore the return value of `git_config_set_in_file`.
As this leaves the submodule in an inconsistent state, we instead
want to inform the user that something has gone wrong by printing
an error and aborting the program.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
index f4c3eff179b5f25e5d09c26348c107d0582455f2..c7e1ea2799a4b5031f64595639a6125d29d993e4 100644 (file)
@@ -245,8 +245,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
        p = git_pathdup_submodule(path, "config");
        if (!p)
                die(_("could not get submodule directory for '%s'"), path);
-       git_config_set_in_file(p, "core.worktree",
-                              relative_path(sb.buf, sm_gitdir, &rel_path));
+       git_config_set_in_file_or_die(p, "core.worktree",
+                                     relative_path(sb.buf, sm_gitdir, &rel_path));
        strbuf_release(&sb);
        strbuf_release(&rel_path);
        free(sm_gitdir);