Skip to content

Commit 3e42cb3

Browse files
szedergitster
authored andcommitted
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 <[email protected]> Reviewed-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cae598d commit 3e42cb3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

builtin/clone.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
889889
const struct ref *our_head_points_at;
890890
struct ref *mapped_refs;
891891
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;
893894
struct strbuf branch_top = STRBUF_INIT, reflog_msg = STRBUF_INIT;
894895
struct transport *transport = NULL;
895896
const char *src_ref_prefix = "refs/heads/";
@@ -1066,7 +1067,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
10661067
strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
10671068
}
10681069

1069-
strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
10701070
strbuf_addf(&key, "remote.%s.url", option_origin);
10711071
git_config_set(key.buf, repo);
10721072
strbuf_reset(&key);
@@ -1080,9 +1080,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
10801080
if (option_required_reference.nr || option_optional_reference.nr)
10811081
setup_reference();
10821082

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);
10861086

10871087
remote = remote_get(option_origin);
10881088
transport = transport_get(remote, remote->url[0]);
@@ -1239,7 +1239,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
12391239
strbuf_release(&reflog_msg);
12401240
strbuf_release(&branch_top);
12411241
strbuf_release(&key);
1242-
strbuf_release(&value);
1242+
strbuf_release(&default_refspec);
12431243
junk_mode = JUNK_LEAVE_ALL;
12441244

12451245
refspec_clear(&rs);

0 commit comments

Comments
 (0)