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

[PATCH 1/3] refspec: group related structures and functions

From
Patrick Steinhardt <ps@pks.im>
Date
Jul 16, 2026, 12:38 UTC
Message-ID
<20260716-pks-refspec-wo-the-repository-v1-1-aa40844d067f@pks.im>
In-Reply-To
<20260716-pks-refspec-wo-the-repository-v1-0-aa40844d067f@pks.im>

Reorganize the refspec header a bit so that structures and their related functions are grouped closer together. While at it, fix a couple of style violations.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 refspec.h | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/refspec.h b/refspec.h
index 8b04f9995e..832d6f923c 100644
--- a/refspec.h
+++ b/refspec.h
@@ -1,6 +1,9 @@
 #ifndef REFSPEC_H
 #define REFSPEC_H
 
+struct string_list;
+struct strvec;
+
 #define TAG_REFSPEC "refs/tags/*:refs/tags/*"
 
 /**
@@ -30,10 +33,9 @@ struct refspec_item {
 	char *raw;
 };
 
-struct string_list;
-
-#define REFSPEC_INIT_FETCH { .fetch = 1 }
-#define REFSPEC_INIT_PUSH { .fetch = 0 }
+int refspec_item_init_fetch(struct refspec_item *item, const char *refspec);
+int refspec_item_init_push(struct refspec_item *item, const char *refspec);
+void refspec_item_clear(struct refspec_item *item);
 
 /**
  * An array of strings can be parsed into a struct refspec using
@@ -47,20 +49,20 @@ struct refspec {
 	unsigned fetch : 1;
 };
 
-int refspec_item_init_fetch(struct refspec_item *item, const char *refspec);
-int refspec_item_init_push(struct refspec_item *item, const char *refspec);
-void refspec_item_clear(struct refspec_item *item);
+#define REFSPEC_INIT_FETCH { .fetch = 1 }
+#define REFSPEC_INIT_PUSH { .fetch = 0 }
+
 void refspec_init_fetch(struct refspec *rs);
 void refspec_init_push(struct refspec *rs);
+void refspec_clear(struct refspec *rs);
+
 void refspec_append(struct refspec *rs, const char *refspec);
 __attribute__((format (printf,2,3)))
 void refspec_appendf(struct refspec *rs, const char *fmt, ...);
 void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
-void refspec_clear(struct refspec *rs);
 
 int valid_fetch_refspec(const char *refspec);
 
-struct strvec;
 /*
  * Determine what <prefix> values to pass to the peer in ref-prefix lines
  * (see linkgit:gitprotocol-v2[5]).
@@ -76,7 +78,7 @@ int refname_matches_negative_refspec_item(const char *refname, struct refspec *r
  * Returns 1 if refname matches pattern, 0 otherwise.
  */
 int match_refname_with_pattern(const char *pattern, const char *refname,
-				   const char *replacement, char **result);
+			       const char *replacement, char **result);
 
 /*
  * Queries a refspec for a match and updates the query item.
@@ -89,8 +91,8 @@ int refspec_find_match(struct refspec *rs, struct refspec_item *query);
  * list.
  */
 void refspec_find_all_matches(struct refspec *rs,
-				    struct refspec_item *query,
-				    struct string_list *results);
+			      struct refspec_item *query,
+			      struct string_list *results);
 
 /*
  * Remove all entries in the input list which match any negative refspec in
-- 
2.55.0.313.g8d093f411d.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 2 of 6 in “refspec: remove dependency on `the_repository`”
  1. 0/3 refspec: remove dependency on `the_repository`Patrick Steinhardt, Jul 16, 2026
  2. 1/3 refspec: group related structures and functionsPatrick Steinhardt, Jul 16, 2026
  3. 2/3 refspec: let callers pass in hash algorithm when parsing itemsPatrick Steinhardt, Jul 16, 2026
  4. 3/3 refspec: stop depending on `the_repository`Patrick Steinhardt, Jul 16, 2026
  5. Junio C HamanoJul 16, 2026
  6. Patrick SteinhardtJul 17, 2026

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.