@@ -77,13 +77,12 @@ static int fetch_prune_tags_config = -1; /* unspecified */
77
77
static int prune_tags = -1 ; /* unspecified */
78
78
#define PRUNE_TAGS_BY_DEFAULT 0 /* do we prune tags by default? */
79
79
80
- static int all , append , dry_run , force , keep , multiple , update_head_ok ;
80
+ static int append , dry_run , force , keep , update_head_ok ;
81
81
static int write_fetch_head = 1 ;
82
82
static int verbosity , deepen_relative , set_upstream , refetch ;
83
83
static int progress = -1 ;
84
- static int enable_auto_gc = 1 ;
85
- static int tags = TAGS_DEFAULT , unshallow , update_shallow , deepen ;
86
- static int max_jobs = -1 , submodule_fetch_jobs_config = -1 ;
84
+ static int tags = TAGS_DEFAULT , update_shallow , deepen ;
85
+ static int submodule_fetch_jobs_config = -1 ;
87
86
static int fetch_parallel_config = 1 ;
88
87
static int atomic_fetch ;
89
88
static enum transport_family family ;
@@ -94,17 +93,11 @@ static struct string_list deepen_not = STRING_LIST_INIT_NODUP;
94
93
static struct strbuf default_rla = STRBUF_INIT ;
95
94
static struct transport * gtransport ;
96
95
static struct transport * gsecondary ;
97
- static const char * submodule_prefix = "" ;
98
96
static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT ;
99
- static int recurse_submodules_cli = RECURSE_SUBMODULES_DEFAULT ;
100
- static int recurse_submodules_default = RECURSE_SUBMODULES_ON_DEMAND ;
101
97
static struct refspec refmap = REFSPEC_INIT_FETCH ;
102
98
static struct list_objects_filter_options filter_options = LIST_OBJECTS_FILTER_INIT ;
103
99
static struct string_list server_options = STRING_LIST_INIT_DUP ;
104
100
static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP ;
105
- static int fetch_write_commit_graph = -1 ;
106
- static int stdin_refspecs = 0 ;
107
- static int negotiate_only ;
108
101
109
102
struct fetch_config {
110
103
enum display_format display_format ;
@@ -180,92 +173,6 @@ static int parse_refmap_arg(const struct option *opt, const char *arg, int unset
180
173
return 0 ;
181
174
}
182
175
183
- static struct option builtin_fetch_options [] = {
184
- OPT__VERBOSITY (& verbosity ),
185
- OPT_BOOL (0 , "all" , & all ,
186
- N_ ("fetch from all remotes" )),
187
- OPT_BOOL (0 , "set-upstream" , & set_upstream ,
188
- N_ ("set upstream for git pull/fetch" )),
189
- OPT_BOOL ('a' , "append" , & append ,
190
- N_ ("append to .git/FETCH_HEAD instead of overwriting" )),
191
- OPT_BOOL (0 , "atomic" , & atomic_fetch ,
192
- N_ ("use atomic transaction to update references" )),
193
- OPT_STRING (0 , "upload-pack" , & upload_pack , N_ ("path" ),
194
- N_ ("path to upload pack on remote end" )),
195
- OPT__FORCE (& force , N_ ("force overwrite of local reference" ), 0 ),
196
- OPT_BOOL ('m' , "multiple" , & multiple ,
197
- N_ ("fetch from multiple remotes" )),
198
- OPT_SET_INT ('t' , "tags" , & tags ,
199
- N_ ("fetch all tags and associated objects" ), TAGS_SET ),
200
- OPT_SET_INT ('n' , NULL , & tags ,
201
- N_ ("do not fetch all tags (--no-tags)" ), TAGS_UNSET ),
202
- OPT_INTEGER ('j' , "jobs" , & max_jobs ,
203
- N_ ("number of submodules fetched in parallel" )),
204
- OPT_BOOL (0 , "prefetch" , & prefetch ,
205
- N_ ("modify the refspec to place all refs within refs/prefetch/" )),
206
- OPT_BOOL ('p' , "prune" , & prune ,
207
- N_ ("prune remote-tracking branches no longer on remote" )),
208
- OPT_BOOL ('P' , "prune-tags" , & prune_tags ,
209
- N_ ("prune local tags no longer on remote and clobber changed tags" )),
210
- OPT_CALLBACK_F (0 , "recurse-submodules" , & recurse_submodules_cli , N_ ("on-demand" ),
211
- N_ ("control recursive fetching of submodules" ),
212
- PARSE_OPT_OPTARG , option_fetch_parse_recurse_submodules ),
213
- OPT_BOOL (0 , "dry-run" , & dry_run ,
214
- N_ ("dry run" )),
215
- OPT_BOOL (0 , "write-fetch-head" , & write_fetch_head ,
216
- N_ ("write fetched references to the FETCH_HEAD file" )),
217
- OPT_BOOL ('k' , "keep" , & keep , N_ ("keep downloaded pack" )),
218
- OPT_BOOL ('u' , "update-head-ok" , & update_head_ok ,
219
- N_ ("allow updating of HEAD ref" )),
220
- OPT_BOOL (0 , "progress" , & progress , N_ ("force progress reporting" )),
221
- OPT_STRING (0 , "depth" , & depth , N_ ("depth" ),
222
- N_ ("deepen history of shallow clone" )),
223
- OPT_STRING (0 , "shallow-since" , & deepen_since , N_ ("time" ),
224
- N_ ("deepen history of shallow repository based on time" )),
225
- OPT_STRING_LIST (0 , "shallow-exclude" , & deepen_not , N_ ("revision" ),
226
- N_ ("deepen history of shallow clone, excluding rev" )),
227
- OPT_INTEGER (0 , "deepen" , & deepen_relative ,
228
- N_ ("deepen history of shallow clone" )),
229
- OPT_SET_INT_F (0 , "unshallow" , & unshallow ,
230
- N_ ("convert to a complete repository" ),
231
- 1 , PARSE_OPT_NONEG ),
232
- OPT_SET_INT_F (0 , "refetch" , & refetch ,
233
- N_ ("re-fetch without negotiating common commits" ),
234
- 1 , PARSE_OPT_NONEG ),
235
- { OPTION_STRING , 0 , "submodule-prefix" , & submodule_prefix , N_ ("dir" ),
236
- N_ ("prepend this to submodule path output" ), PARSE_OPT_HIDDEN },
237
- OPT_CALLBACK_F (0 , "recurse-submodules-default" ,
238
- & recurse_submodules_default , N_ ("on-demand" ),
239
- N_ ("default for recursive fetching of submodules "
240
- "(lower priority than config files)" ),
241
- PARSE_OPT_HIDDEN , option_fetch_parse_recurse_submodules ),
242
- OPT_BOOL (0 , "update-shallow" , & update_shallow ,
243
- N_ ("accept refs that update .git/shallow" )),
244
- OPT_CALLBACK_F (0 , "refmap" , NULL , N_ ("refmap" ),
245
- N_ ("specify fetch refmap" ), PARSE_OPT_NONEG , parse_refmap_arg ),
246
- OPT_STRING_LIST ('o' , "server-option" , & server_options , N_ ("server-specific" ), N_ ("option to transmit" )),
247
- OPT_SET_INT ('4' , "ipv4" , & family , N_ ("use IPv4 addresses only" ),
248
- TRANSPORT_FAMILY_IPV4 ),
249
- OPT_SET_INT ('6' , "ipv6" , & family , N_ ("use IPv6 addresses only" ),
250
- TRANSPORT_FAMILY_IPV6 ),
251
- OPT_STRING_LIST (0 , "negotiation-tip" , & negotiation_tip , N_ ("revision" ),
252
- N_ ("report that we have only objects reachable from this object" )),
253
- OPT_BOOL (0 , "negotiate-only" , & negotiate_only ,
254
- N_ ("do not fetch a packfile; instead, print ancestors of negotiation tips" )),
255
- OPT_PARSE_LIST_OBJECTS_FILTER (& filter_options ),
256
- OPT_BOOL (0 , "auto-maintenance" , & enable_auto_gc ,
257
- N_ ("run 'maintenance --auto' after fetching" )),
258
- OPT_BOOL (0 , "auto-gc" , & enable_auto_gc ,
259
- N_ ("run 'maintenance --auto' after fetching" )),
260
- OPT_BOOL (0 , "show-forced-updates" , & fetch_show_forced_updates ,
261
- N_ ("check for forced-updates on all updated branches" )),
262
- OPT_BOOL (0 , "write-commit-graph" , & fetch_write_commit_graph ,
263
- N_ ("write the commit-graph after fetching" )),
264
- OPT_BOOL (0 , "stdin" , & stdin_refspecs ,
265
- N_ ("accept refspecs from stdin" )),
266
- OPT_END ()
267
- };
268
-
269
176
static void unlock_pack (unsigned int flags )
270
177
{
271
178
if (gtransport )
@@ -2167,12 +2074,108 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2167
2074
struct fetch_config config = {
2168
2075
.display_format = DISPLAY_FORMAT_FULL ,
2169
2076
};
2170
- int i ;
2077
+ const char * submodule_prefix = "" ;
2171
2078
const char * bundle_uri ;
2172
2079
struct string_list list = STRING_LIST_INIT_DUP ;
2173
2080
struct remote * remote = NULL ;
2081
+ int all = 0 , multiple = 0 ;
2174
2082
int result = 0 ;
2175
2083
int prune_tags_ok = 1 ;
2084
+ int enable_auto_gc = 1 ;
2085
+ int unshallow = 0 ;
2086
+ int max_jobs = -1 ;
2087
+ int recurse_submodules_cli = RECURSE_SUBMODULES_DEFAULT ;
2088
+ int recurse_submodules_default = RECURSE_SUBMODULES_ON_DEMAND ;
2089
+ int fetch_write_commit_graph = -1 ;
2090
+ int stdin_refspecs = 0 ;
2091
+ int negotiate_only = 0 ;
2092
+ int i ;
2093
+
2094
+ struct option builtin_fetch_options [] = {
2095
+ OPT__VERBOSITY (& verbosity ),
2096
+ OPT_BOOL (0 , "all" , & all ,
2097
+ N_ ("fetch from all remotes" )),
2098
+ OPT_BOOL (0 , "set-upstream" , & set_upstream ,
2099
+ N_ ("set upstream for git pull/fetch" )),
2100
+ OPT_BOOL ('a' , "append" , & append ,
2101
+ N_ ("append to .git/FETCH_HEAD instead of overwriting" )),
2102
+ OPT_BOOL (0 , "atomic" , & atomic_fetch ,
2103
+ N_ ("use atomic transaction to update references" )),
2104
+ OPT_STRING (0 , "upload-pack" , & upload_pack , N_ ("path" ),
2105
+ N_ ("path to upload pack on remote end" )),
2106
+ OPT__FORCE (& force , N_ ("force overwrite of local reference" ), 0 ),
2107
+ OPT_BOOL ('m' , "multiple" , & multiple ,
2108
+ N_ ("fetch from multiple remotes" )),
2109
+ OPT_SET_INT ('t' , "tags" , & tags ,
2110
+ N_ ("fetch all tags and associated objects" ), TAGS_SET ),
2111
+ OPT_SET_INT ('n' , NULL , & tags ,
2112
+ N_ ("do not fetch all tags (--no-tags)" ), TAGS_UNSET ),
2113
+ OPT_INTEGER ('j' , "jobs" , & max_jobs ,
2114
+ N_ ("number of submodules fetched in parallel" )),
2115
+ OPT_BOOL (0 , "prefetch" , & prefetch ,
2116
+ N_ ("modify the refspec to place all refs within refs/prefetch/" )),
2117
+ OPT_BOOL ('p' , "prune" , & prune ,
2118
+ N_ ("prune remote-tracking branches no longer on remote" )),
2119
+ OPT_BOOL ('P' , "prune-tags" , & prune_tags ,
2120
+ N_ ("prune local tags no longer on remote and clobber changed tags" )),
2121
+ OPT_CALLBACK_F (0 , "recurse-submodules" , & recurse_submodules_cli , N_ ("on-demand" ),
2122
+ N_ ("control recursive fetching of submodules" ),
2123
+ PARSE_OPT_OPTARG , option_fetch_parse_recurse_submodules ),
2124
+ OPT_BOOL (0 , "dry-run" , & dry_run ,
2125
+ N_ ("dry run" )),
2126
+ OPT_BOOL (0 , "write-fetch-head" , & write_fetch_head ,
2127
+ N_ ("write fetched references to the FETCH_HEAD file" )),
2128
+ OPT_BOOL ('k' , "keep" , & keep , N_ ("keep downloaded pack" )),
2129
+ OPT_BOOL ('u' , "update-head-ok" , & update_head_ok ,
2130
+ N_ ("allow updating of HEAD ref" )),
2131
+ OPT_BOOL (0 , "progress" , & progress , N_ ("force progress reporting" )),
2132
+ OPT_STRING (0 , "depth" , & depth , N_ ("depth" ),
2133
+ N_ ("deepen history of shallow clone" )),
2134
+ OPT_STRING (0 , "shallow-since" , & deepen_since , N_ ("time" ),
2135
+ N_ ("deepen history of shallow repository based on time" )),
2136
+ OPT_STRING_LIST (0 , "shallow-exclude" , & deepen_not , N_ ("revision" ),
2137
+ N_ ("deepen history of shallow clone, excluding rev" )),
2138
+ OPT_INTEGER (0 , "deepen" , & deepen_relative ,
2139
+ N_ ("deepen history of shallow clone" )),
2140
+ OPT_SET_INT_F (0 , "unshallow" , & unshallow ,
2141
+ N_ ("convert to a complete repository" ),
2142
+ 1 , PARSE_OPT_NONEG ),
2143
+ OPT_SET_INT_F (0 , "refetch" , & refetch ,
2144
+ N_ ("re-fetch without negotiating common commits" ),
2145
+ 1 , PARSE_OPT_NONEG ),
2146
+ { OPTION_STRING , 0 , "submodule-prefix" , & submodule_prefix , N_ ("dir" ),
2147
+ N_ ("prepend this to submodule path output" ), PARSE_OPT_HIDDEN },
2148
+ OPT_CALLBACK_F (0 , "recurse-submodules-default" ,
2149
+ & recurse_submodules_default , N_ ("on-demand" ),
2150
+ N_ ("default for recursive fetching of submodules "
2151
+ "(lower priority than config files)" ),
2152
+ PARSE_OPT_HIDDEN , option_fetch_parse_recurse_submodules ),
2153
+ OPT_BOOL (0 , "update-shallow" , & update_shallow ,
2154
+ N_ ("accept refs that update .git/shallow" )),
2155
+ OPT_CALLBACK_F (0 , "refmap" , NULL , N_ ("refmap" ),
2156
+ N_ ("specify fetch refmap" ), PARSE_OPT_NONEG , parse_refmap_arg ),
2157
+ OPT_STRING_LIST ('o' , "server-option" , & server_options , N_ ("server-specific" ), N_ ("option to transmit" )),
2158
+ OPT_SET_INT ('4' , "ipv4" , & family , N_ ("use IPv4 addresses only" ),
2159
+ TRANSPORT_FAMILY_IPV4 ),
2160
+ OPT_SET_INT ('6' , "ipv6" , & family , N_ ("use IPv6 addresses only" ),
2161
+ TRANSPORT_FAMILY_IPV6 ),
2162
+ OPT_STRING_LIST (0 , "negotiation-tip" , & negotiation_tip , N_ ("revision" ),
2163
+ N_ ("report that we have only objects reachable from this object" )),
2164
+ OPT_BOOL (0 , "negotiate-only" , & negotiate_only ,
2165
+ N_ ("do not fetch a packfile; instead, print ancestors of negotiation tips" )),
2166
+ OPT_PARSE_LIST_OBJECTS_FILTER (& filter_options ),
2167
+ OPT_BOOL (0 , "auto-maintenance" , & enable_auto_gc ,
2168
+ N_ ("run 'maintenance --auto' after fetching" )),
2169
+ OPT_BOOL (0 , "auto-gc" , & enable_auto_gc ,
2170
+ N_ ("run 'maintenance --auto' after fetching" )),
2171
+ OPT_BOOL (0 , "show-forced-updates" , & fetch_show_forced_updates ,
2172
+ N_ ("check for forced-updates on all updated branches" )),
2173
+ OPT_BOOL (0 , "write-commit-graph" , & fetch_write_commit_graph ,
2174
+ N_ ("write the commit-graph after fetching" )),
2175
+ OPT_BOOL (0 , "stdin" , & stdin_refspecs ,
2176
+ N_ ("accept refspecs from stdin" )),
2177
+ OPT_END ()
2178
+ };
2176
2179
2177
2180
packet_trace_identity ("fetch" );
2178
2181
0 commit comments