Skip to content

Commit cca7c97

Browse files
jaysoffiangitster
authored andcommitted
builtin-remote: make get_remote_ref_states() always populate states.tracked
When not querying the remote, show() was having to populate states.tracked itself. It makes more sense for get_remote_ref_states() to do this consistently. Since show() is the only caller of get_remote_ref_states() with query=0, this change does not affect other callers. Signed-off-by: Jay Soffian <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e0cc81e commit cca7c97

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

builtin-remote.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,20 @@ static void free_remote_ref_states(struct ref_states *states)
632632
string_list_clear(&states->tracked, 0);
633633
}
634634

635+
static int append_ref_to_tracked_list(const char *refname,
636+
const unsigned char *sha1, int flags, void *cb_data)
637+
{
638+
struct ref_states *states = cb_data;
639+
struct refspec refspec;
640+
641+
memset(&refspec, 0, sizeof(refspec));
642+
refspec.dst = (char *)refname;
643+
if (!remote_find_tracking(states->remote, &refspec))
644+
string_list_append(abbrev_branch(refspec.src), &states->tracked);
645+
646+
return 0;
647+
}
648+
635649
static int get_remote_ref_states(const char *name,
636650
struct ref_states *states,
637651
int query)
@@ -652,21 +666,8 @@ static int get_remote_ref_states(const char *name,
652666
transport_disconnect(transport);
653667

654668
get_ref_states(remote_refs, states);
655-
}
656-
657-
return 0;
658-
}
659-
660-
static int append_ref_to_tracked_list(const char *refname,
661-
const unsigned char *sha1, int flags, void *cb_data)
662-
{
663-
struct ref_states *states = cb_data;
664-
struct refspec refspec;
665-
666-
memset(&refspec, 0, sizeof(refspec));
667-
refspec.dst = (char *)refname;
668-
if (!remote_find_tracking(states->remote, &refspec))
669-
string_list_append(abbrev_branch(refspec.src), &states->tracked);
669+
} else
670+
for_each_ref(append_ref_to_tracked_list, states);
670671

671672
return 0;
672673
}
@@ -720,8 +721,6 @@ static int show(int argc, const char **argv)
720721
"prune')", &states.stale, "");
721722
}
722723

723-
if (no_query)
724-
for_each_ref(append_ref_to_tracked_list, &states);
725724
show_list(" Tracked remote branch%s", &states.tracked, "");
726725

727726
if (states.remote->push_refspec_nr) {

0 commit comments

Comments
 (0)