Skip to content

Commit 1a90dfe

Browse files
pks-tgitster
authored andcommitted
submodule: die on config error when linking modules
When trying to connect a submodule with its corresponding repository in '.git/modules' we try to set the core.worktree setting in the submodule, which may fail due to an error encountered in `git_config_set_in_file`. The function is used in the git-mv command when trying to move a submodule to another location. We already die when renaming a file fails but do not pay attention to the case where updating the connection between submodule and its repository fails. As this leaves the repository in an inconsistent state, as well, abort the program by dying early and presenting the failure to the user. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bd25f89 commit 1a90dfe

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

submodule.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,11 +1034,9 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
10341034
/* Update core.worktree setting */
10351035
strbuf_reset(&file_name);
10361036
strbuf_addf(&file_name, "%s/config", git_dir);
1037-
if (git_config_set_in_file(file_name.buf, "core.worktree",
1038-
relative_path(real_work_tree, git_dir,
1039-
&rel_path)))
1040-
die(_("Could not set core.worktree in %s"),
1041-
file_name.buf);
1037+
git_config_set_in_file_or_die(file_name.buf, "core.worktree",
1038+
relative_path(real_work_tree, git_dir,
1039+
&rel_path));
10421040

10431041
strbuf_release(&file_name);
10441042
strbuf_release(&rel_path);

0 commit comments

Comments
 (0)