@@ -53,6 +53,7 @@ static int option_shallow_submodules;
53
53
static int deepen ;
54
54
static char * option_template , * option_depth , * option_since ;
55
55
static char * option_origin = NULL ;
56
+ static char * remote_name = "origin" ;
56
57
static char * option_branch = NULL ;
57
58
static struct string_list option_not = STRING_LIST_INIT_NODUP ;
58
59
static const char * real_git_dir ;
@@ -721,7 +722,7 @@ static void update_head(const struct ref *our, const struct ref *remote,
721
722
if (!option_bare ) {
722
723
update_ref (msg , "HEAD" , & our -> old_oid , NULL , 0 ,
723
724
UPDATE_REFS_DIE_ON_ERR );
724
- install_branch_config (0 , head , option_origin , our -> name );
725
+ install_branch_config (0 , head , remote_name , our -> name );
725
726
}
726
727
} else if (our ) {
727
728
struct commit * c = lookup_commit_reference (the_repository ,
@@ -919,12 +920,12 @@ static void write_refspec_config(const char *src_ref_prefix,
919
920
}
920
921
/* Configure the remote */
921
922
if (value .len ) {
922
- strbuf_addf (& key , "remote.%s.fetch" , option_origin );
923
+ strbuf_addf (& key , "remote.%s.fetch" , remote_name );
923
924
git_config_set_multivar (key .buf , value .buf , "^$" , 0 );
924
925
strbuf_reset (& key );
925
926
926
927
if (option_mirror ) {
927
- strbuf_addf (& key , "remote.%s.mirror" , option_origin );
928
+ strbuf_addf (& key , "remote.%s.mirror" , remote_name );
928
929
git_config_set (key .buf , "true" );
929
930
strbuf_reset (& key );
930
931
}
@@ -1009,11 +1010,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1009
1010
option_no_checkout = 1 ;
1010
1011
}
1011
1012
1012
- if (! option_origin )
1013
- option_origin = "origin" ;
1013
+ if (option_origin )
1014
+ remote_name = option_origin ;
1014
1015
1015
- if (!valid_remote_name (option_origin ))
1016
- die (_ ("'%s' is not a valid remote name" ), option_origin );
1016
+ if (!valid_remote_name (remote_name ))
1017
+ die (_ ("'%s' is not a valid remote name" ), remote_name );
1017
1018
1018
1019
repo_name = argv [0 ];
1019
1020
@@ -1164,15 +1165,15 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1164
1165
1165
1166
git_config_set ("core.bare" , "true" );
1166
1167
} else {
1167
- strbuf_addf (& branch_top , "refs/remotes/%s/" , option_origin );
1168
+ strbuf_addf (& branch_top , "refs/remotes/%s/" , remote_name );
1168
1169
}
1169
1170
1170
- strbuf_addf (& key , "remote.%s.url" , option_origin );
1171
+ strbuf_addf (& key , "remote.%s.url" , remote_name );
1171
1172
git_config_set (key .buf , repo );
1172
1173
strbuf_reset (& key );
1173
1174
1174
1175
if (option_no_tags ) {
1175
- strbuf_addf (& key , "remote.%s.tagOpt" , option_origin );
1176
+ strbuf_addf (& key , "remote.%s.tagOpt" , remote_name );
1176
1177
git_config_set (key .buf , "--no-tags" );
1177
1178
strbuf_reset (& key );
1178
1179
}
@@ -1183,7 +1184,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1183
1184
if (option_sparse_checkout && git_sparse_checkout_init (dir ))
1184
1185
return 1 ;
1185
1186
1186
- remote = remote_get (option_origin );
1187
+ remote = remote_get (remote_name );
1187
1188
1188
1189
strbuf_addf (& default_refspec , "+%s*:%s*" , src_ref_prefix ,
1189
1190
branch_top .buf );
@@ -1296,15 +1297,15 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1296
1297
1297
1298
if (!our_head_points_at )
1298
1299
die (_ ("Remote branch %s not found in upstream %s" ),
1299
- option_branch , option_origin );
1300
+ option_branch , remote_name );
1300
1301
}
1301
1302
else
1302
1303
our_head_points_at = remote_head_points_at ;
1303
1304
}
1304
1305
else {
1305
1306
if (option_branch )
1306
1307
die (_ ("Remote branch %s not found in upstream %s" ),
1307
- option_branch , option_origin );
1308
+ option_branch , remote_name );
1308
1309
1309
1310
warning (_ ("You appear to have cloned an empty repository." ));
1310
1311
mapped_refs = NULL ;
@@ -1316,7 +1317,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1316
1317
const char * branch = git_default_branch_name ();
1317
1318
char * ref = xstrfmt ("refs/heads/%s" , branch );
1318
1319
1319
- install_branch_config (0 , branch , option_origin , ref );
1320
+ install_branch_config (0 , branch , remote_name , ref );
1320
1321
free (ref );
1321
1322
}
1322
1323
}
@@ -1325,7 +1326,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1325
1326
remote_head_points_at , & branch_top );
1326
1327
1327
1328
if (filter_options .choice )
1328
- partial_clone_register (option_origin , & filter_options );
1329
+ partial_clone_register (remote_name , & filter_options );
1329
1330
1330
1331
if (is_local )
1331
1332
clone_local (path , git_dir );
0 commit comments