builtin-remote: refactor duplicated cleanup code
This patch moves identical lines of code into a cleanup function. The function has two callers and is about to gain a third. Also removed a bogus NEEDSWORK comment per Daniel Barkalow: Actually, the comment is wrong; "remote" comes from remote_get(), which returns things from a cache in remote.c; there could be a remote_put() to let the code know that the caller is done with the object, but it wouldn't presently do anything. 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
88733235615b24198599b533f9d02578ef739536
1 file changed
+9
-8
builtin-remote.c
+9
-8
@@ -632,6 +632,13 @@ static void show_list(const char *title, struct string_list *list,
632
printf(" %s\n", list->items[i].string);
633
}
634
635
+static void free_remote_ref_states(struct ref_states *states)
636
+{
637
+ string_list_clear(&states->new, 0);
638
+ string_list_clear(&states->stale, 0);
639
+ string_list_clear(&states->tracked, 0);
640
+}
641
+
642
static int get_remote_ref_states(const char *name,
643
struct ref_states *states,
644
int query)
@@ -738,10 +745,7 @@ static int show(int argc, const char **argv)
745
}
746
}
747
741
- /* NEEDSWORK: free remote */
742
- string_list_clear(&states.new, 0);
743
- string_list_clear(&states.stale, 0);
744
- string_list_clear(&states.tracked, 0);
748
+ free_remote_ref_states(&states);
749
}
750
751
return result;
@@ -792,10 +796,7 @@ static int prune(int argc, const char **argv)
796
warn_dangling_symref(dangling_msg, refname);
797
}
798
795
- /* NEEDSWORK: free remote */
796
- string_list_clear(&states.new, 0);
797
- string_list_clear(&states.stale, 0);
798
- string_list_clear(&states.tracked, 0);
799
+ free_remote_ref_states(&states);
800
}
801
802
return result;