builtin-remote: rename variables and eliminate redundant function call
- The variable name "remote" is used as both a "char *" and as a "struct remote *"; this is confusing, so rename the former to remote_name. - Consistently refer to the refs returned by transport_get_remote_refs() as remote_refs. - There is no need to call "sort_string_list(&branch_list)" as branch_list is populated via string_list_insert(), which maintains its order. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jay Soffian committed
Feb 25, 2009 at 03:32 UTC
e0cc81e63c7bb603545c90e47d4c6398f6347dfb
1 file changed
+12
-12
builtin-remote.c
+12
-12
@@ -143,7 +143,7 @@ static int add(int argc, const char **argv)
143
}
144
145
struct branch_info {
146
- char *remote;
146
+ char *remote_name;
147
struct string_list merge;
148
};
149
@@ -182,9 +182,9 @@ static int config_read_branches(const char *key, const char *value, void *cb)
182
item->util = xcalloc(sizeof(struct branch_info), 1);
183
info = item->util;
184
if (type == REMOTE) {
185
- if (info->remote)
185
+ if (info->remote_name)
186
warning("more than one branch.%s", key);
187
- info->remote = xstrdup(value);
187
+ info->remote_name = xstrdup(value);
188
} else {
189
char *space = strchr(value, ' ');
190
value = abbrev_branch(value);
@@ -206,7 +206,6 @@ static void read_branches(void)
206
if (branch_list.nr)
207
return;
208
git_config(config_read_branches, NULL);
209
- sort_string_list(&branch_list);
209
}
210
211
struct ref_states {
@@ -238,13 +237,14 @@ static int handle_one_branch(const char *refname,
237
return 0;
238
}
239
241
-static int get_ref_states(const struct ref *ref, struct ref_states *states)
240
+static int get_ref_states(const struct ref *remote_refs, struct ref_states *states)
241
{
242
struct ref *fetch_map = NULL, **tail = &fetch_map;
243
+ struct ref *ref;
244
int i;
245
246
for (i = 0; i < states->remote->fetch_refspec_nr; i++)
247
- if (get_fetch_map(ref, states->remote->fetch + i, &tail, 1))
247
+ if (get_fetch_map(remote_refs, states->remote->fetch + i, &tail, 1))
248
die("Could not get fetch map for refspec %s",
249
states->remote->fetch_refspec[i]);
250
@@ -459,7 +459,7 @@ static int mv(int argc, const char **argv)
459
for (i = 0; i < branch_list.nr; i++) {
460
struct string_list_item *item = branch_list.items + i;
461
struct branch_info *info = item->util;
462
- if (info->remote && !strcmp(info->remote, rename.old)) {
462
+ if (info->remote_name && !strcmp(info->remote_name, rename.old)) {
463
strbuf_reset(&buf);
464
strbuf_addf(&buf, "branch.%s.remote", item->string);
465
if (git_config_set(buf.buf, rename.new)) {
@@ -569,7 +569,7 @@ static int rm(int argc, const char **argv)
569
for (i = 0; i < branch_list.nr; i++) {
570
struct string_list_item *item = branch_list.items + i;
571
struct branch_info *info = item->util;
572
- if (info->remote && !strcmp(info->remote, remote->name)) {
572
+ if (info->remote_name && !strcmp(info->remote_name, remote->name)) {
573
const char *keys[] = { "remote", "merge", NULL }, **k;
574
for (k = keys; *k; k++) {
575
strbuf_reset(&buf);
@@ -637,7 +637,7 @@ static int get_remote_ref_states(const char *name,
637
int query)
638
{
639
struct transport *transport;
640
- const struct ref *ref;
640
+ const struct ref *remote_refs;
641
642
states->remote = remote_get(name);
643
if (!states->remote)
@@ -648,10 +648,10 @@ static int get_remote_ref_states(const char *name,
648
if (query) {
649
transport = transport_get(NULL, states->remote->url_nr > 0 ?
650
states->remote->url[0] : NULL);
651
- ref = transport_get_remote_refs(transport);
651
+ remote_refs = transport_get_remote_refs(transport);
652
transport_disconnect(transport);
653
654
- get_ref_states(ref, states);
654
+ get_ref_states(remote_refs, states);
655
}
656
657
return 0;
@@ -701,7 +701,7 @@ static int show(int argc, const char **argv)
701
struct branch_info *info = branch->util;
702
int j;
703
704
- if (!info->merge.nr || strcmp(*argv, info->remote))
704
+ if (!info->merge.nr || strcmp(*argv, info->remote_name))
705
continue;
706
printf(" Remote branch%s merged with 'git pull' "
707
"while on branch %s\n ",