Skip to content

Commit 16eefc8

Browse files
bmwillgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eace274 commit 16eefc8

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

builtin/fast-export.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ static int use_done_feature;
3636
static int no_data;
3737
static int full_tree;
3838
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;
4140
static int anonymize;
4241

4342
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)
830829
if (dwim_ref(e->name, strlen(e->name), &oid, &full_name) != 1)
831830
continue;
832831

833-
if (refspecs) {
832+
if (refspecs.nr) {
834833
char *private;
835-
private = apply_refspecs(refspecs, refspecs_nr, full_name);
834+
private = apply_refspecs(refspecs.items, refspecs.nr, full_name);
836835
if (private) {
837836
free(full_name);
838837
full_name = private;
@@ -978,8 +977,8 @@ static void import_marks(char *input_file)
978977
static void handle_deletes(void)
979978
{
980979
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];
983982
if (*refspec->src)
984983
continue;
985984

@@ -1040,18 +1039,12 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
10401039
usage_with_options (fast_export_usage, options);
10411040

10421041
if (refspecs_list.nr) {
1043-
const char **refspecs_str;
10441042
int i;
10451043

1046-
ALLOC_ARRAY(refspecs_str, refspecs_list.nr);
10471044
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);
10521046

10531047
string_list_clear(&refspecs_list, 1);
1054-
free(refspecs_str);
10551048
}
10561049

10571050
if (use_done_feature)
@@ -1090,7 +1083,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
10901083
if (use_done_feature)
10911084
printf("done\n");
10921085

1093-
free_refspec(refspecs_nr, refspecs);
1086+
refspec_clear(&refspecs);
10941087

10951088
return 0;
10961089
}

0 commit comments

Comments
 (0)