Skip to content

Commit f30c77b

Browse files
committed
remote add: use strvec to store tracking branches
Store the list of branches to track in a ’struct strvec' instead of a 'struct string_list'. This in preparation for the next commit where it will be convenient to have them stored in a NULL terminated array. This means that we now duplicate the strings when storing them but the overhead is not significant. Signed-off-by: Phillip Wood <[email protected]>
1 parent a8dfe40 commit f30c77b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

builtin/remote.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static int add(int argc, const char **argv, const char *prefix)
158158
{
159159
int fetch = 0, fetch_tags = TAGS_DEFAULT;
160160
unsigned mirror = MIRROR_NONE;
161-
struct string_list track = STRING_LIST_INIT_NODUP;
161+
struct strvec track = STRVEC_INIT;
162162
const char *master = NULL;
163163
struct remote *remote;
164164
struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;
@@ -171,8 +171,8 @@ static int add(int argc, const char **argv, const char *prefix)
171171
N_("import all tags and associated objects when fetching\n"
172172
"or do not fetch any tag at all (--no-tags)"),
173173
TAGS_SET),
174-
OPT_STRING_LIST('t', "track", &track, N_("branch"),
175-
N_("branch(es) to track")),
174+
OPT_STRVEC('t', "track", &track, N_("branch"),
175+
N_("branch(es) to track")),
176176
OPT_STRING('m', "master", &master, N_("branch"), N_("master branch")),
177177
OPT_CALLBACK_F(0, "mirror", &mirror, "(push|fetch)",
178178
N_("set up remote as a mirror to push to or fetch from"),
@@ -210,10 +210,9 @@ static int add(int argc, const char **argv, const char *prefix)
210210
strbuf_reset(&buf);
211211
strbuf_addf(&buf, "remote.%s.fetch", name);
212212
if (track.nr == 0)
213-
string_list_append(&track, "*");
213+
strvec_push(&track, "*");
214214
for (i = 0; i < track.nr; i++) {
215-
add_branch(buf.buf, track.items[i].string,
216-
name, mirror, &buf2);
215+
add_branch(buf.buf, track.v[i], name, mirror, &buf2);
217216
}
218217
}
219218

@@ -246,7 +245,7 @@ static int add(int argc, const char **argv, const char *prefix)
246245

247246
strbuf_release(&buf);
248247
strbuf_release(&buf2);
249-
string_list_clear(&track, 0);
248+
strvec_clear(&track);
250249

251250
return 0;
252251
}

0 commit comments

Comments
 (0)