summaryrefslogtreecommitdiff
path: root/fetch-pack.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <junkio@cox.net>2006-05-28 22:47:53 -0700
committerLibravatar Junio C Hamano <junkio@cox.net>2006-05-28 22:47:53 -0700
commit0a2586c807fadc4b13a741e693471765870f6bb4 (patch)
tree9c62558c76d02057e71f6152c8d73b9cb1cf536e /fetch-pack.c
parentMerge branch 'jc/dirwalk-n-cache-tree' into jc/cache-tree (diff)
parentRemove "tree->entries" tree-entry list from tree parser (diff)
downloadtgif-0a2586c807fadc4b13a741e693471765870f6bb4.tar.xz
Merge branch 'lt/tree' into jc/lt-tree-n-cache-tree
* lt/tree: (98 commits) Remove "tree->entries" tree-entry list from tree parser Switch "read_tree_recursive()" over to tree-walk functionality Make "tree_entry" have a SHA1 instead of a union of object pointers Add raw tree buffer info to "struct tree" Don't use "sscanf()" for tree mode scanning git-fetch: avoid using "case ... in (arm)" mailinfo: skip bogus UNIX From line inside body mailinfo: More carefully parse header lines in read_one_header_line() Allow in body headers beyond the in body header prefix. More accurately detect header lines in read_one_header_line In handle_body only read a line if we don't already have one. Refactor commit messge handling. Move B and Q decoding into check header. Make read_one_header_line return a flag not a length. Fix memory leak in "git rev-list --objects" gitview: Move the console error messages to message dialog gitview: Add key binding for F5. Let git-clone to pass --template=dir option to git-init-db. Make cvsexportcommit create parent directories as needed. Document current cvsexportcommit limitations. ... Conflicts: Makefile, builtin.h, git.c are trivially resolved. builtin-read-tree.c needed adjustment for the tree parser change.
Diffstat (limited to 'fetch-pack.c')
-rw-r--r--fetch-pack.c66
1 files changed, 51 insertions, 15 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index a3bcad016f..8daa93d024 100644
--- a/fetch-pack.c
+++ b/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)
{
- struct ref *prev, *current, *next;
-
- for (prev = NULL, current = *refs; current; current = next) {
- next = current->next;
- if ((!memcmp(current->name, "refs/", 5) &&
- check_ref_format(current->name + 5)) ||
- (!fetch_all &&
- !path_match(current->name, nr_match, match))) {
- if (prev == NULL)
- *refs = next;
- else
- prev->next = next;
- free(current);
- } else
- prev = current;
+ struct ref **return_refs;
+ struct ref *newlist = NULL;
+ struct ref **newtail = &newlist;
+ struct ref *ref, *next;
+ struct ref *fastarray[32];
+
+ if (nr_match && !fetch_all) {
+ if (ARRAY_SIZE(fastarray) < nr_match)
+ return_refs = xcalloc(nr_match, sizeof(struct ref *));
+ else {
+ return_refs = fastarray;
+ memset(return_refs, 0, sizeof(struct ref *) * nr_match);
+ }
+ }
+ 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)