[PATCH 1/3] builtin-remote: move duplicated cleanup code its own function

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jay Soffian
Date: Tuesday, February 10, 2009 - 11:01 pm

Moved some identical lines of code into their own function in
preparation for adding additional functionality which will use this
function as well.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
 builtin-remote.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/builtin-remote.c b/builtin-remote.c
index db18bcf..00e7ca5 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -632,6 +632,14 @@ 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)
+{
+	/* NEEDSWORK: free remote */
+	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 +746,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;
@@ -786,10 +791,7 @@ static int prune(int argc, const char **argv)
 			       abbrev_ref(refname, "refs/remotes/"));
 		}
 
-		/* 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;
-- 
1.6.2.rc0.187.g9fcfb

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/3] remote HEAD improvements, Jay Soffian, (Tue Feb 10, 11:01 pm)
[PATCH 1/3] builtin-remote: move duplicated cleanup code i ..., Jay Soffian, (Tue Feb 10, 11:01 pm)
[PATCH 3/3] builtin-remote: add sethead verb, Jay Soffian, (Tue Feb 10, 11:01 pm)
Re: [PATCH 0/3] remote HEAD improvements, Jeff King, (Wed Feb 11, 5:17 pm)