clone: use a more appropriate variable name for the default refspec
cmd_clone() declares two strbufs 'key' and 'value' on the same line, suggesting that they are used to contruct a config variable's name and value. However, this is not the case: 'key' is used to construct the names of multiple config variables, while 'value' is never used as a value for any of those config variables, or for any other config variable for that matter, but only to contruct the default fetch refspec. Let's rename 'value' to 'default_refspec' to make the intent clearer. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
SZEDER Gábor committed
Nov 14, 2018 at 11:46 UTC
3e42cb3b67bef525d4bd8416d44ac1f1a1f7a495
1 file changed
+6
-6
builtin/clone.c
+6
-6
@@ -889,7 +889,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
889
const struct ref *our_head_points_at;
890
struct ref *mapped_refs;
891
const struct ref *ref;
892
- struct strbuf key = STRBUF_INIT, value = STRBUF_INIT;
892
+ struct strbuf key = STRBUF_INIT;
893
+ struct strbuf default_refspec = STRBUF_INIT;
894
struct strbuf branch_top = STRBUF_INIT, reflog_msg = STRBUF_INIT;
895
struct transport *transport = NULL;
896
const char *src_ref_prefix = "refs/heads/";
@@ -1066,7 +1067,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1067
strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
1068
}
1069
1069
- strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
1070
strbuf_addf(&key, "remote.%s.url", option_origin);
1071
git_config_set(key.buf, repo);
1072
strbuf_reset(&key);
@@ -1080,9 +1080,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1080
if (option_required_reference.nr || option_optional_reference.nr)
1081
setup_reference();
1082
1083
- refspec_append(&rs, value.buf);
1084
-
1085
- strbuf_reset(&value);
1083
+ strbuf_addf(&default_refspec, "+%s*:%s*", src_ref_prefix,
1084
+ branch_top.buf);
1085
+ refspec_append(&rs, default_refspec.buf);
1086
1087
remote = remote_get(option_origin);
1088
transport = transport_get(remote, remote->url[0]);
@@ -1239,7 +1239,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1239
strbuf_release(&reflog_msg);
1240
strbuf_release(&branch_top);
1241
strbuf_release(&key);
1242
- strbuf_release(&value);
1242
+ strbuf_release(&default_refspec);
1243
junk_mode = JUNK_LEAVE_ALL;
1244
1245
refspec_clear(&rs);