Skip to content

Commit 992f25d

Browse files
derrickstoleegitster
authored andcommitted
fetch: use ref_namespaces during prefetch
The "refs/prefetch/" namespace is used by 'git fetch --prefetch' as a replacement of the destination of the refpsec for a remote. Git also removes refspecs that include tags. Instead of using string literals for the 'refs/tags/ and 'refs/prefetch/' namespaces, use the entries in the ref_namespaces array. This kind of change could be done in many places around the codebase, but we are isolating only to this change because of the way the refs/prefetch/ namespace somewhat motivated the creation of the ref_namespaces array. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 863a8ae commit 992f25d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

builtin/fetch.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,9 @@ static void filter_prefetch_refspec(struct refspec *rs)
490490
continue;
491491
if (!rs->items[i].dst ||
492492
(rs->items[i].src &&
493-
!strncmp(rs->items[i].src, "refs/tags/", 10))) {
493+
!strncmp(rs->items[i].src,
494+
ref_namespace[NAMESPACE_TAGS].ref,
495+
strlen(ref_namespace[NAMESPACE_TAGS].ref)))) {
494496
int j;
495497

496498
free(rs->items[i].src);
@@ -506,7 +508,7 @@ static void filter_prefetch_refspec(struct refspec *rs)
506508
}
507509

508510
old_dst = rs->items[i].dst;
509-
strbuf_addstr(&new_dst, "refs/prefetch/");
511+
strbuf_addstr(&new_dst, ref_namespace[NAMESPACE_PREFETCH].ref);
510512

511513
/*
512514
* If old_dst starts with "refs/", then place

0 commit comments

Comments
 (0)