refspec: group related structures and functions
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Jul 16, 2026 at 14:38 UTC
991ec2741d723d0737bd5410f01b7f98b89d9186
1 file changed
+14
-12
refspec.h
+14
-12
@@ -1,6 +1,9 @@
1
#ifndef REFSPEC_H
2
#define REFSPEC_H
3
4
+struct string_list;
5
+struct strvec;
6
+
7
#define TAG_REFSPEC "refs/tags/*:refs/tags/*"
8
9
/**
@@ -30,10 +33,9 @@ struct refspec_item {
33
char *raw;
34
};
35
33
-struct string_list;
34
-
35
-#define REFSPEC_INIT_FETCH { .fetch = 1 }
36
-#define REFSPEC_INIT_PUSH { .fetch = 0 }
36
+int refspec_item_init_fetch(struct refspec_item *item, const char *refspec);
37
+int refspec_item_init_push(struct refspec_item *item, const char *refspec);
38
+void refspec_item_clear(struct refspec_item *item);
39
40
/**
41
* An array of strings can be parsed into a struct refspec using
@@ -47,20 +49,20 @@ struct refspec {
49
unsigned fetch : 1;
50
};
51
50
-int refspec_item_init_fetch(struct refspec_item *item, const char *refspec);
51
-int refspec_item_init_push(struct refspec_item *item, const char *refspec);
52
-void refspec_item_clear(struct refspec_item *item);
52
+#define REFSPEC_INIT_FETCH { .fetch = 1 }
53
+#define REFSPEC_INIT_PUSH { .fetch = 0 }
54
+
55
void refspec_init_fetch(struct refspec *rs);
56
void refspec_init_push(struct refspec *rs);
57
+void refspec_clear(struct refspec *rs);
58
+
59
void refspec_append(struct refspec *rs, const char *refspec);
60
__attribute__((format (printf,2,3)))
61
void refspec_appendf(struct refspec *rs, const char *fmt, ...);
62
void refspec_appendn(struct refspec *rs, const char **refspecs, int nr);
59
-void refspec_clear(struct refspec *rs);
63
64
int valid_fetch_refspec(const char *refspec);
65
63
-struct strvec;
66
/*
67
* Determine what <prefix> values to pass to the peer in ref-prefix lines
68
* (see linkgit:gitprotocol-v2[5]).
@@ -76,7 +78,7 @@ int refname_matches_negative_refspec_item(const char *refname, struct refspec *r
78
* Returns 1 if refname matches pattern, 0 otherwise.
79
*/
80
int match_refname_with_pattern(const char *pattern, const char *refname,
79
- const char *replacement, char **result);
81
+ const char *replacement, char **result);
82
83
/*
84
* 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);
91
* list.
92
*/
93
void refspec_find_all_matches(struct refspec *rs,
92
- struct refspec_item *query,
93
- struct string_list *results);
94
+ struct refspec_item *query,
95
+ struct string_list *results);
96
97
/*
98
* Remove all entries in the input list which match any negative refspec in