builtin-apply: prevent non-explicit permission changes
[gitweb.git] / commit.c
index 22ce7768639465f896e52b08a73cf5605940700b..09cf167423ee88f0b4e8117dd3e0a2bd8ccda887 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -193,7 +193,7 @@ static void prepare_commit_graft(void)
        commit_graft_prepared = 1;
 }
 
-static struct commit_graft *lookup_commit_graft(const unsigned char *sha1)
+struct commit_graft *lookup_commit_graft(const unsigned char *sha1)
 {
        int pos;
        prepare_commit_graft();
@@ -243,7 +243,6 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
        unsigned char parent[20];
        struct commit_list **pptr;
        struct commit_graft *graft;
-       unsigned n_refs = 0;
 
        if (item->object.parsed)
                return 0;
@@ -255,8 +254,6 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
                return error("bad tree pointer in commit %s",
                             sha1_to_hex(item->object.sha1));
        item->tree = lookup_tree(parent);
-       if (item->tree)
-               n_refs++;
        bufptr += 46; /* "tree " + "hex sha1" + "\n" */
        pptr = &item->parents;
 
@@ -272,10 +269,8 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
                if (graft)
                        continue;
                new_parent = lookup_commit(parent);
-               if (new_parent) {
+               if (new_parent)
                        pptr = &commit_list_insert(new_parent, pptr)->next;
-                       n_refs++;
-               }
        }
        if (graft) {
                int i;
@@ -285,22 +280,10 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
                        if (!new_parent)
                                continue;
                        pptr = &commit_list_insert(new_parent, pptr)->next;
-                       n_refs++;
                }
        }
        item->date = parse_commit_date(bufptr, tail);
 
-       if (track_object_refs) {
-               unsigned i = 0;
-               struct commit_list *p;
-               struct object_refs *refs = alloc_object_refs(n_refs);
-               if (item->tree)
-                       refs->ref[i++] = &item->tree->object;
-               for (p = item->parents; p; p = p->next)
-                       refs->ref[i++] = &p->item->object;
-               set_object_refs(&item->object, refs);
-       }
-
        return 0;
 }
 
@@ -445,8 +428,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
        /* Mark them and clear the indegree */
        for (next = orig; next; next = next->next) {
                struct commit *commit = next->item;
-               commit->object.flags |= TOPOSORT;
-               commit->indegree = 0;
+               commit->indegree = 1;
        }
 
        /* update the indegree */
@@ -455,7 +437,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
                while (parents) {
                        struct commit *parent = parents->item;
 
-                       if (parent->object.flags & TOPOSORT)
+                       if (parent->indegree)
                                parent->indegree++;
                        parents = parents->next;
                }
@@ -473,7 +455,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
        for (next = orig; next; next = next->next) {
                struct commit *commit = next->item;
 
-               if (!commit->indegree)
+               if (commit->indegree == 1)
                        insert = &commit_list_insert(commit, insert)->next;
        }
 
@@ -495,7 +477,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
                for (parents = commit->parents; parents ; parents = parents->next) {
                        struct commit *parent=parents->item;
 
-                       if (!(parent->object.flags & TOPOSORT))
+                       if (!parent->indegree)
                                continue;
 
                        /*
@@ -503,7 +485,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
                         * when all their children have been emitted thereby
                         * guaranteeing topological order.
                         */
-                       if (!--parent->indegree) {
+                       if (--parent->indegree == 1) {
                                if (!lifo)
                                        insert_by_date(parent, &work);
                                else
@@ -514,7 +496,7 @@ void sort_in_topological_order(struct commit_list ** list, int lifo)
                 * work_item is a commit all of whose children
                 * have already been emitted. we can emit it now.
                 */
-               commit->object.flags &= ~TOPOSORT;
+               commit->indegree = 0;
                *pptr = work_item;
                pptr = &work_item->next;
        }