git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jay Soffian <jaysoffian@gmail.com>
Date
Feb 11, 2009, 06:01 UTC
Message-ID
<1234332083-45147-2-git-send-email-jaysoffian@gmail.com>
In-Reply-To
<1234332083-45147-1-git-send-email-jaysoffian@gmail.com>

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
Previous: Jay SoffianNext: Jay Soffian
Message 2 of 17 in “remote HEAD improvements”
  1. 0/3 remote HEAD improvementsJay Soffian, Feb 11, 2009
  2. 1/3 builtin-remote: move duplicated cleanup code its own functionJay Soffian, Feb 11, 2009
  3. 2/3 builtin-remote: teach show to display remote HEADJay Soffian, Feb 11, 2009
  4. 3/3 builtin-remote: add sethead verbJay Soffian, Feb 11, 2009
  5. Jeff KingFeb 12, 2009
  6. Jay SoffianFeb 12, 2009
  7. Jeff KingFeb 12, 2009
  8. Daniel BarkalowFeb 12, 2009
  9. Junio C HamanoFeb 12, 2009
  10. Daniel BarkalowFeb 12, 2009
  11. Jay SoffianFeb 12, 2009
  12. Daniel BarkalowFeb 12, 2009
  13. Jeff KingFeb 12, 2009
  14. Jay SoffianFeb 12, 2009
  15. Jeff KingFeb 12, 2009
  16. Daniel BarkalowFeb 12, 2009
  17. Jeff KingFeb 12, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.