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>

Brandon Williams committed May 16, 2018 at 15:57 UTC 16eefc8eb37dfb26c83bbd0a393b494e3734cb97
1 file changed +7 -14
builtin/fast-export.c
+7 -14
@@ -36,8 +36,7 @@ static int use_done_feature;
36 static int no_data;
37 static int full_tree;
38 static struct string_list extra_refs = STRING_LIST_INIT_NODUP;
39 -static struct refspec_item *refspecs;
40 -static int refspecs_nr;
39 +static struct refspec refspecs = REFSPEC_INIT_FETCH;
40 static int anonymize;
41
42 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)
829 if (dwim_ref(e->name, strlen(e->name), &oid, &full_name) != 1)
830 continue;
831
833 - if (refspecs) {
832 + if (refspecs.nr) {
833 char *private;
835 - private = apply_refspecs(refspecs, refspecs_nr, full_name);
834 + private = apply_refspecs(refspecs.items, refspecs.nr, full_name);
835 if (private) {
836 free(full_name);
837 full_name = private;
@@ -978,8 +977,8 @@ static void import_marks(char *input_file)
977 static void handle_deletes(void)
978 {
979 int i;
981 - for (i = 0; i < refspecs_nr; i++) {
982 - struct refspec_item *refspec = &refspecs[i];
980 + for (i = 0; i < refspecs.nr; i++) {
981 + struct refspec_item *refspec = &refspecs.items[i];
982 if (*refspec->src)
983 continue;
984
@@ -1040,18 +1039,12 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
1039 usage_with_options (fast_export_usage, options);
1040
1041 if (refspecs_list.nr) {
1043 - const char **refspecs_str;
1042 int i;
1043
1046 - ALLOC_ARRAY(refspecs_str, refspecs_list.nr);
1044 for (i = 0; i < refspecs_list.nr; i++)
1048 - refspecs_str[i] = refspecs_list.items[i].string;
1049 -
1050 - refspecs_nr = refspecs_list.nr;
1051 - refspecs = parse_fetch_refspec(refspecs_nr, refspecs_str);
1045 + refspec_append(&refspecs, refspecs_list.items[i].string);
1046
1047 string_list_clear(&refspecs_list, 1);
1054 - free(refspecs_str);
1048 }
1049
1050 if (use_done_feature)
@@ -1090,7 +1083,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
1083 if (use_done_feature)
1084 printf("done\n");
1085
1093 - free_refspec(refspecs_nr, refspecs);
1086 + refspec_clear(&refspecs);
1087
1088 return 0;
1089 }