Merge branch 'jc/fetch-sorted' into next
* jc/fetch-sorted: fetch-pack: output refs in the order they were given on the command line.
This commit is contained in:
commit
0c1d1ae43b
@ -100,7 +100,7 @@ int path_match(const char *path, int nr, char **match)
|
|||||||
if (pathlen > len && path[pathlen - len - 1] != '/')
|
if (pathlen > len && path[pathlen - len - 1] != '/')
|
||||||
continue;
|
continue;
|
||||||
*s = 0;
|
*s = 0;
|
||||||
return 1;
|
return (i + 1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
64
fetch-pack.c
64
fetch-pack.c
@ -262,22 +262,58 @@ static void mark_recent_complete_commits(unsigned long cutoff)
|
|||||||
|
|
||||||
static void filter_refs(struct ref **refs, int nr_match, char **match)
|
static void filter_refs(struct ref **refs, int nr_match, char **match)
|
||||||
{
|
{
|
||||||
struct ref *prev, *current, *next;
|
struct ref **return_refs;
|
||||||
|
struct ref *newlist = NULL;
|
||||||
|
struct ref **newtail = &newlist;
|
||||||
|
struct ref *ref, *next;
|
||||||
|
struct ref *fastarray[32];
|
||||||
|
|
||||||
for (prev = NULL, current = *refs; current; current = next) {
|
if (nr_match && !fetch_all) {
|
||||||
next = current->next;
|
if (ARRAY_SIZE(fastarray) < nr_match)
|
||||||
if ((!memcmp(current->name, "refs/", 5) &&
|
return_refs = xcalloc(nr_match, sizeof(struct ref *));
|
||||||
check_ref_format(current->name + 5)) ||
|
else {
|
||||||
(!fetch_all &&
|
return_refs = fastarray;
|
||||||
!path_match(current->name, nr_match, match))) {
|
memset(return_refs, 0, sizeof(struct ref *) * nr_match);
|
||||||
if (prev == NULL)
|
}
|
||||||
*refs = next;
|
|
||||||
else
|
|
||||||
prev->next = next;
|
|
||||||
free(current);
|
|
||||||
} else
|
|
||||||
prev = current;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return_refs = NULL;
|
||||||
|
|
||||||
|
for (ref = *refs; ref; ref = next) {
|
||||||
|
next = ref->next;
|
||||||
|
if (!memcmp(ref->name, "refs/", 5) &&
|
||||||
|
check_ref_format(ref->name + 5))
|
||||||
|
; /* trash */
|
||||||
|
else if (fetch_all) {
|
||||||
|
*newtail = ref;
|
||||||
|
ref->next = NULL;
|
||||||
|
newtail = &ref->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int order = path_match(ref->name, nr_match, match);
|
||||||
|
if (order) {
|
||||||
|
return_refs[order-1] = ref;
|
||||||
|
continue; /* we will link it later */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!fetch_all) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < nr_match; i++) {
|
||||||
|
ref = return_refs[i];
|
||||||
|
if (ref) {
|
||||||
|
*newtail = ref;
|
||||||
|
ref->next = NULL;
|
||||||
|
newtail = &ref->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (return_refs != fastarray)
|
||||||
|
free(return_refs);
|
||||||
|
}
|
||||||
|
*refs = newlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int everything_local(struct ref **refs, int nr_match, char **match)
|
static int everything_local(struct ref **refs, int nr_match, char **match)
|
||||||
|
Loading…
Reference in New Issue
Block a user