summaryrefslogtreecommitdiff
path: root/builtin-remote.c
diff options
context:
space:
mode:
authorJay Soffian <jaysoffian@gmail.com>2009-02-25 08:32:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-02-27 23:19:08 (GMT)
commit88733235615b24198599b533f9d02578ef739536 (patch)
treed7917b0dc308fee526640a983caf56b20b2b1eb0 /builtin-remote.c
parentc6f5a7a916b36fc9dd00bb6dce3b68260579abe1 (diff)
downloadgit-88733235615b24198599b533f9d02578ef739536.zip
git-88733235615b24198599b533f9d02578ef739536.tar.gz
git-88733235615b24198599b533f9d02578ef739536.tar.bz2
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>
Diffstat (limited to 'builtin-remote.c')
-rw-r--r--builtin-remote.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/builtin-remote.c b/builtin-remote.c
index ac69d37..b89a353 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -632,6 +632,13 @@ static void show_list(const char *title, struct string_list *list,
printf(" %s\n", list->items[i].string);
}
+static void free_remote_ref_states(struct ref_states *states)
+{
+ string_list_clear(&states->new, 0);
+ string_list_clear(&states->stale, 0);
+ string_list_clear(&states->tracked, 0);
+}
+
static int get_remote_ref_states(const char *name,
struct ref_states *states,
int query)
@@ -738,10 +745,7 @@ static int show(int argc, const char **argv)
}
}
- /* NEEDSWORK: free remote */
- string_list_clear(&states.new, 0);
- string_list_clear(&states.stale, 0);
- string_list_clear(&states.tracked, 0);
+ free_remote_ref_states(&states);
}
return result;
@@ -792,10 +796,7 @@ static int prune(int argc, const char **argv)
warn_dangling_symref(dangling_msg, refname);
}
- /* NEEDSWORK: free remote */
- string_list_clear(&states.new, 0);
- string_list_clear(&states.stale, 0);
- string_list_clear(&states.tracked, 0);
+ free_remote_ref_states(&states);
}
return result;