Skip to content

Commit e0aaa29

Browse files
iabervongitster
authored andcommitted
Have a constant extern refspec for "--tags"
The refspec refs/tags/*:refs/tags/* is sufficiently common and generic to merit having a constant instead of generating it as needed. Signed-off-by: Daniel Barkalow <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bef70b2 commit e0aaa29

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

builtin-fetch.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,8 @@ static struct ref *get_ref_map(struct transport *transport,
127127
/* Merge everything on the command line, but not --tags */
128128
for (rm = ref_map; rm; rm = rm->next)
129129
rm->merge = 1;
130-
if (tags == TAGS_SET) {
131-
struct refspec refspec;
132-
refspec.src = "refs/tags/";
133-
refspec.dst = "refs/tags/";
134-
refspec.pattern = 1;
135-
refspec.force = 0;
136-
get_fetch_map(remote_refs, &refspec, &tail, 0);
137-
}
130+
if (tags == TAGS_SET)
131+
get_fetch_map(remote_refs, tag_refspec, &tail, 0);
138132
} else {
139133
/* Use the defaults */
140134
struct remote *remote = transport->remote;

remote.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
#include "remote.h"
33
#include "refs.h"
44

5+
static struct refspec s_tag_refspec = {
6+
0,
7+
1,
8+
"refs/tags/",
9+
"refs/tags/"
10+
};
11+
12+
const struct refspec *tag_refspec = &s_tag_refspec;
13+
514
struct counted_string {
615
size_t len;
716
const char *s;

remote.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ struct refspec {
5151
char *dst;
5252
};
5353

54+
extern const struct refspec *tag_refspec;
55+
5456
struct ref *alloc_ref(unsigned namelen);
5557

5658
struct ref *copy_ref_list(const struct ref *ref);

0 commit comments

Comments
 (0)