fast-export: convert to use struct refspec

Convert fast-export to use 'struct refspec' instead of using a list of
refspec_item's.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Brandon Williams
2018-05-16 15:57:59 -07:00
committed by Junio C Hamano
parent eace274df8
commit 16eefc8eb3

View File

@ -36,8 +36,7 @@ static int use_done_feature;
static int no_data; static int no_data;
static int full_tree; static int full_tree;
static struct string_list extra_refs = STRING_LIST_INIT_NODUP; static struct string_list extra_refs = STRING_LIST_INIT_NODUP;
static struct refspec_item *refspecs; static struct refspec refspecs = REFSPEC_INIT_FETCH;
static int refspecs_nr;
static int anonymize; static int anonymize;
static int parse_opt_signed_tag_mode(const struct option *opt, static int parse_opt_signed_tag_mode(const struct option *opt,
@ -830,9 +829,9 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
if (dwim_ref(e->name, strlen(e->name), &oid, &full_name) != 1) if (dwim_ref(e->name, strlen(e->name), &oid, &full_name) != 1)
continue; continue;
if (refspecs) { if (refspecs.nr) {
char *private; char *private;
private = apply_refspecs(refspecs, refspecs_nr, full_name); private = apply_refspecs(refspecs.items, refspecs.nr, full_name);
if (private) { if (private) {
free(full_name); free(full_name);
full_name = private; full_name = private;
@ -978,8 +977,8 @@ static void import_marks(char *input_file)
static void handle_deletes(void) static void handle_deletes(void)
{ {
int i; int i;
for (i = 0; i < refspecs_nr; i++) { for (i = 0; i < refspecs.nr; i++) {
struct refspec_item *refspec = &refspecs[i]; struct refspec_item *refspec = &refspecs.items[i];
if (*refspec->src) if (*refspec->src)
continue; continue;
@ -1040,18 +1039,12 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
usage_with_options (fast_export_usage, options); usage_with_options (fast_export_usage, options);
if (refspecs_list.nr) { if (refspecs_list.nr) {
const char **refspecs_str;
int i; int i;
ALLOC_ARRAY(refspecs_str, refspecs_list.nr);
for (i = 0; i < refspecs_list.nr; i++) for (i = 0; i < refspecs_list.nr; i++)
refspecs_str[i] = refspecs_list.items[i].string; refspec_append(&refspecs, refspecs_list.items[i].string);
refspecs_nr = refspecs_list.nr;
refspecs = parse_fetch_refspec(refspecs_nr, refspecs_str);
string_list_clear(&refspecs_list, 1); string_list_clear(&refspecs_list, 1);
free(refspecs_str);
} }
if (use_done_feature) if (use_done_feature)
@ -1090,7 +1083,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
if (use_done_feature) if (use_done_feature)
printf("done\n"); printf("done\n");
free_refspec(refspecs_nr, refspecs); refspec_clear(&refspecs);
return 0; return 0;
} }