26
26
#include "run-command.h"
27
27
#include "connected.h"
28
28
#include "packfile.h"
29
+ #include "list-objects-filter-options.h"
29
30
30
31
/*
31
32
* Overall FIXMEs:
@@ -60,6 +61,7 @@ static struct string_list option_optional_reference = STRING_LIST_INIT_NODUP;
60
61
static int option_dissociate ;
61
62
static int max_jobs = -1 ;
62
63
static struct string_list option_recurse_submodules = STRING_LIST_INIT_NODUP ;
64
+ static struct list_objects_filter_options filter_options ;
63
65
64
66
static int recurse_submodules_cb (const struct option * opt ,
65
67
const char * arg , int unset )
@@ -135,6 +137,7 @@ static struct option builtin_clone_options[] = {
135
137
TRANSPORT_FAMILY_IPV4 ),
136
138
OPT_SET_INT ('6' , "ipv6" , & family , N_ ("use IPv6 addresses only" ),
137
139
TRANSPORT_FAMILY_IPV6 ),
140
+ OPT_PARSE_LIST_OBJECTS_FILTER (& filter_options ),
138
141
OPT_END ()
139
142
};
140
143
@@ -886,6 +889,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
886
889
struct refspec * refspec ;
887
890
const char * fetch_pattern ;
888
891
892
+ fetch_if_missing = 0 ;
893
+
889
894
packet_trace_identity ("clone" );
890
895
argc = parse_options (argc , argv , prefix , builtin_clone_options ,
891
896
builtin_clone_usage , 0 );
@@ -1073,6 +1078,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1073
1078
warning (_ ("--shallow-since is ignored in local clones; use file:// instead." ));
1074
1079
if (option_not .nr )
1075
1080
warning (_ ("--shallow-exclude is ignored in local clones; use file:// instead." ));
1081
+ if (filter_options .choice )
1082
+ warning (_ ("--filter is ignored in local clones; use file:// instead." ));
1076
1083
if (!access (mkpath ("%s/shallow" , path ), F_OK )) {
1077
1084
if (option_local > 0 )
1078
1085
warning (_ ("source repository is shallow, ignoring --local" ));
@@ -1104,7 +1111,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1104
1111
transport_set_option (transport , TRANS_OPT_UPLOADPACK ,
1105
1112
option_upload_pack );
1106
1113
1107
- if (transport -> smart_options && !deepen )
1114
+ if (filter_options .choice ) {
1115
+ transport_set_option (transport , TRANS_OPT_LIST_OBJECTS_FILTER ,
1116
+ filter_options .filter_spec );
1117
+ transport_set_option (transport , TRANS_OPT_FROM_PROMISOR , "1" );
1118
+ }
1119
+
1120
+ if (transport -> smart_options && !deepen && !filter_options .choice )
1108
1121
transport -> smart_options -> check_self_contained_and_connected = 1 ;
1109
1122
1110
1123
refs = transport_get_remote_refs (transport );
@@ -1164,13 +1177,17 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1164
1177
write_refspec_config (src_ref_prefix , our_head_points_at ,
1165
1178
remote_head_points_at , & branch_top );
1166
1179
1180
+ if (filter_options .choice )
1181
+ partial_clone_register ("origin" , & filter_options );
1182
+
1167
1183
if (is_local )
1168
1184
clone_local (path , git_dir );
1169
1185
else if (refs && complete_refs_before_fetch )
1170
1186
transport_fetch_refs (transport , mapped_refs );
1171
1187
1172
1188
update_remote_refs (refs , mapped_refs , remote_head_points_at ,
1173
- branch_top .buf , reflog_msg .buf , transport , !is_local );
1189
+ branch_top .buf , reflog_msg .buf , transport ,
1190
+ !is_local && !filter_options .choice );
1174
1191
1175
1192
update_head (our_head_points_at , remote_head , reflog_msg .buf );
1176
1193
@@ -1191,6 +1208,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1191
1208
}
1192
1209
1193
1210
junk_mode = JUNK_LEAVE_REPO ;
1211
+ fetch_if_missing = 1 ;
1194
1212
err = checkout (submodule_progress );
1195
1213
1196
1214
strbuf_release (& reflog_msg );
0 commit comments