@@ -1235,7 +1235,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
12351235 }
12361236 else {
12371237 const char * branch ;
1238- char * ref ;
1238+ const char * ref ;
1239+ char * ref_free = NULL ;
12391240
12401241 if (option_branch )
12411242 die (_ ("Remote branch %s not found in upstream %s" ),
@@ -1251,17 +1252,16 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
12511252 skip_prefix (transport_ls_refs_options .unborn_head_target ,
12521253 "refs/heads/" , & branch )) {
12531254 ref = transport_ls_refs_options .unborn_head_target ;
1254- transport_ls_refs_options .unborn_head_target = NULL ;
12551255 create_symref ("HEAD" , ref , reflog_msg .buf );
12561256 } else {
12571257 branch = git_default_branch_name (0 );
1258- ref = xstrfmt ("refs/heads/%s" , branch );
1258+ ref_free = xstrfmt ("refs/heads/%s" , branch );
1259+ ref = ref_free ;
12591260 }
12601261
12611262 if (!option_bare )
12621263 install_branch_config (0 , branch , remote_name , ref );
1263-
1264- free (ref );
1264+ free (ref_free );
12651265 }
12661266
12671267 write_refspec_config (src_ref_prefix , our_head_points_at ,
@@ -1313,7 +1313,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
13131313 UNLEAK (repo );
13141314 junk_mode = JUNK_LEAVE_ALL ;
13151315
1316- strvec_clear (& transport_ls_refs_options .ref_prefixes );
1317- free (transport_ls_refs_options .unborn_head_target );
1316+ transport_ls_refs_options_release (& transport_ls_refs_options );
13181317 return err ;
13191318}
0 commit comments