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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Feb 22, 2016 at 12:23 UTC
2ee35c428e0685b4fc3bc2e828326b6fcefb78c0
1 file changed
+4
-4
builtin/clone.c
+4
-4
@@ -783,12 +783,12 @@ static void write_refspec_config(const char *src_ref_prefix,
783
/* Configure the remote */
784
if (value.len) {
785
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);
787
strbuf_reset(&key);
788
789
if (option_mirror) {
790
strbuf_addf(&key, "remote.%s.mirror", option_origin);
791
- git_config_set(key.buf, "true");
791
+ git_config_set_or_die(key.buf, "true");
792
strbuf_reset(&key);
793
}
794
}
@@ -946,14 +946,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
946
src_ref_prefix = "refs/";
947
strbuf_addstr(&branch_top, src_ref_prefix);
948
949
- git_config_set("core.bare", "true");
949
+ git_config_set_or_die("core.bare", "true");
950
} else {
951
strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
952
}
953
954
strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
955
strbuf_addf(&key, "remote.%s.url", option_origin);
956
- git_config_set(key.buf, repo);
956
+ git_config_set_or_die(key.buf, repo);
957
strbuf_reset(&key);
958
959
if (option_reference.nr)