Skip to content

Commit 2ee35c4

Browse files
pks-tgitster
authored andcommitted
clone: die on config error in cmd_clone
The clone command does not check for error codes returned by `git_config_set` functions. This may cause the user to end up with an inconsistent repository without any indication with what went wrong. Fix this problem by dying with an error message when we are unable to write the configuration files to disk. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c397deb commit 2ee35c4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

builtin/clone.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,12 +783,12 @@ static void write_refspec_config(const char *src_ref_prefix,
783783
/* Configure the remote */
784784
if (value.len) {
785785
strbuf_addf(&key, "remote.%s.fetch", option_origin);
786-
git_config_set_multivar(key.buf, value.buf, "^$", 0);
786+
git_config_set_multivar_or_die(key.buf, value.buf, "^$", 0);
787787
strbuf_reset(&key);
788788

789789
if (option_mirror) {
790790
strbuf_addf(&key, "remote.%s.mirror", option_origin);
791-
git_config_set(key.buf, "true");
791+
git_config_set_or_die(key.buf, "true");
792792
strbuf_reset(&key);
793793
}
794794
}
@@ -946,14 +946,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
946946
src_ref_prefix = "refs/";
947947
strbuf_addstr(&branch_top, src_ref_prefix);
948948

949-
git_config_set("core.bare", "true");
949+
git_config_set_or_die("core.bare", "true");
950950
} else {
951951
strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
952952
}
953953

954954
strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
955955
strbuf_addf(&key, "remote.%s.url", option_origin);
956-
git_config_set(key.buf, repo);
956+
git_config_set_or_die(key.buf, repo);
957957
strbuf_reset(&key);
958958

959959
if (option_reference.nr)

0 commit comments

Comments
 (0)