Code

gitweb: Fix "next" link on bottom of page
[git.git] / builtin-fetch-pack.c
index 7b280242244094774c909f67d6a8ed7902389c5a..de1e8d1365769c7c841749901f705c0b6a78eab3 100644 (file)
@@ -26,6 +26,8 @@ static const char fetch_pack_usage[] =
 #define SEEN           (1U << 3)
 #define POPPED         (1U << 4)
 
+static int marked;
+
 /*
  * After sending this many "have"s if we do not get any new ACK , we
  * give up traversing our history.
@@ -61,6 +63,16 @@ static int rev_list_insert_ref(const char *path, const unsigned char *sha1, int
        return 0;
 }
 
+static int clear_marks(const char *path, const unsigned char *sha1, int flag, void *cb_data)
+{
+       struct object *o = deref_tag(parse_object(sha1), path, 0);
+
+       if (o && o->type == OBJ_COMMIT)
+               clear_commit_marks((struct commit *)o,
+                                  COMMON | COMMON_REF | SEEN | POPPED);
+       return 0;
+}
+
 /*
    This function marks a rev and its ancestors as common.
    In some cases, it is desirable to mark only the ancestors (for example
@@ -105,15 +117,15 @@ static const unsigned char* get_rev(void)
 
        while (commit == NULL) {
                unsigned int mark;
-               struct commit_list *parents = NULL;
+               struct commit_list *parents;
 
                if (rev_list == NULL || non_common_revs == 0)
                        return NULL;
 
                commit = rev_list->item;
-               if (!(commit->object.parsed))
-                       if (!parse_commit(commit))
-                               parents = commit->parents;
+               if (!commit->object.parsed)
+                       parse_commit(commit);
+               parents = commit->parents;
 
                commit->object.flags |= POPPED;
                if (!(commit->object.flags & COMMON))
@@ -153,6 +165,10 @@ static int find_common(int fd[2], unsigned char *result_sha1,
        unsigned in_vain = 0;
        int got_continue = 0;
 
+       if (marked)
+               for_each_ref(clear_marks, NULL);
+       marked = 1;
+
        for_each_ref(rev_list_insert_ref, NULL);
 
        fetching = 0;
@@ -619,7 +635,7 @@ static int remove_duplicates(int nr_heads, char **heads)
        return dst;
 }
 
-static int fetch_pack_config(const char *var, const char *value)
+static int fetch_pack_config(const char *var, const char *value, void *cb)
 {
        if (strcmp(var, "fetch.unpacklimit") == 0) {
                fetch_unpack_limit = git_config_int(var, value);
@@ -631,7 +647,7 @@ static int fetch_pack_config(const char *var, const char *value)
                return 0;
        }
 
-       return git_default_config(var, value);
+       return git_default_config(var, value, cb);
 }
 
 static struct lock_file lock;
@@ -641,7 +657,7 @@ static void fetch_pack_setup(void)
        static int did_setup;
        if (did_setup)
                return;
-       git_config(fetch_pack_config);
+       git_config(fetch_pack_config, NULL);
        if (0 <= transfer_unpack_limit)
                unpack_limit = transfer_unpack_limit;
        else if (0 <= fetch_unpack_limit)