@@ -60,8 +60,7 @@ static const char *submodule_prefix = "";
60
60
static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT ;
61
61
static int recurse_submodules_default = RECURSE_SUBMODULES_ON_DEMAND ;
62
62
static int shown_url = 0 ;
63
- static int refmap_alloc , refmap_nr ;
64
- static const char * * refmap_array ;
63
+ static struct refspec refmap = REFSPEC_INIT_FETCH ;
65
64
static struct list_objects_filter_options filter_options ;
66
65
67
66
static int git_fetch_config (const char * k , const char * v , void * cb )
@@ -108,14 +107,12 @@ static int gitmodules_fetch_config(const char *var, const char *value, void *cb)
108
107
109
108
static int parse_refmap_arg (const struct option * opt , const char * arg , int unset )
110
109
{
111
- ALLOC_GROW (refmap_array , refmap_nr + 1 , refmap_alloc );
112
-
113
110
/*
114
111
* "git fetch --refmap='' origin foo"
115
112
* can be used to tell the command not to store anywhere
116
113
*/
117
- if ( * arg )
118
- refmap_array [ refmap_nr ++ ] = arg ;
114
+ refspec_append ( & refmap , arg );
115
+
119
116
return 0 ;
120
117
}
121
118
@@ -403,17 +400,17 @@ static struct ref *get_ref_map(struct transport *transport,
403
400
* by ref_remove_duplicates() in favor of one of these
404
401
* opportunistic entries with FETCH_HEAD_IGNORE.
405
402
*/
406
- if (refmap_array ) {
407
- fetch_refspec = parse_fetch_refspec ( refmap_nr , refmap_array ) ;
408
- fetch_refspec_nr = refmap_nr ;
403
+ if (refmap . nr ) {
404
+ fetch_refspec = refmap . items ;
405
+ fetch_refspec_nr = refmap . nr ;
409
406
} else {
410
407
fetch_refspec = transport -> remote -> fetch .items ;
411
408
fetch_refspec_nr = transport -> remote -> fetch .nr ;
412
409
}
413
410
414
411
for (i = 0 ; i < fetch_refspec_nr ; i ++ )
415
412
get_fetch_map (ref_map , & fetch_refspec [i ], & oref_tail , 1 );
416
- } else if (refmap_array ) {
413
+ } else if (refmap . nr ) {
417
414
die ("--refmap option is only meaningful with command-line refspec(s)." );
418
415
} else {
419
416
/* Use the defaults */
0 commit comments