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 <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jay Soffian committed
Feb 25, 2009 at 03:32 UTC
cca7c97e37719eaee1d31cdaf1e638d19ecd69e4
1 file changed
+16
-17
builtin-remote.c
+16
-17
@@ -632,6 +632,20 @@ static void free_remote_ref_states(struct ref_states *states)
632
string_list_clear(&states->tracked, 0);
633
}
634
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
+
649
static int get_remote_ref_states(const char *name,
650
struct ref_states *states,
651
int query)
@@ -652,21 +666,8 @@ static int get_remote_ref_states(const char *name,
666
transport_disconnect(transport);
667
668
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);
671
672
return 0;
673
}
@@ -720,8 +721,6 @@ static int show(int argc, const char **argv)
721
"prune')", &states.stale, "");
722
}
723
723
- if (no_query)
724
- for_each_ref(append_ref_to_tracked_list, &states);
724
show_list(" Tracked remote branch%s", &states.tracked, "");
725
726
if (states.remote->push_refspec_nr) {