[PATCH] Fix several gcc4 signedness warnings
[git.git] / epoch.c
diff --git a/epoch.c b/epoch.c
index a4c8213..35756a3 100644 (file)
--- a/epoch.c
+++ b/epoch.c
@@ -224,17 +224,13 @@ static int find_base_for_list(struct commit_list *list, struct commit **boundary
        for (; list; list = list->next) {
                struct commit *item = list->item;
 
-               if (item->object.util) {
-                       die("%s:%d:%s: logic error: this should not have happened - commit %s",
-                           __FILE__, __LINE__, __FUNCTION__,
-                           sha1_to_hex(item->object.sha1));
-               }
-
-               new_mass_counter(list->item, get_one());
-               add(&injected, &injected, get_one());
+               if (!item->object.util) {
+                       new_mass_counter(list->item, get_one());
+                       add(&injected, &injected, get_one());
 
-               commit_list_insert(list->item, &cleaner);
-               commit_list_insert(list->item, &pending);
+                       commit_list_insert(list->item, &cleaner);
+                       commit_list_insert(list->item, &pending);
+               }
        }
 
        while (!*boundary && pending && !ret) {
@@ -536,6 +532,8 @@ static int sort_in_merge_order(struct commit *head_of_epoch, emitter_func emitte
 
        ret = parse_commit(head_of_epoch);
 
+       next->object.flags |= BOUNDARY;
+
        while (next && next->parents && !ret && (action != STOP)) {
                struct commit *base = NULL;
 
@@ -604,7 +602,9 @@ int sort_list_in_merge_order(struct commit_list *list, emitter_func emitter)
                }
        }
 
-       if (!reversed->next) {
+       if (!reversed)
+               return ret;
+       else if (!reversed->next) {
                /*
                 * If there is only one element in the list, we can sort it
                 * using sort_in_merge_order.
@@ -621,20 +621,27 @@ int sort_list_in_merge_order(struct commit_list *list, emitter_func emitter)
                        base->object.flags |= BOUNDARY;
 
                while (reversed) {
-                       sort_first_epoch(pop_commit(&reversed), &stack);
-                       if (reversed) {
-                               /*
-                                * If we have more commits to push, then the
-                                * first push for the next parent may (or may
-                                * not) represent a discontinuity with respect
-                                * to the parent currently on the top of
-                                * the stack.
-                                *
-                                * Mark it for checking here, and check it
-                                * with the next push. See sort_first_epoch()
-                                * for more details.
-                                */
-                               stack->item->object.flags |= DISCONTINUITY;
+                       struct commit * next = pop_commit(&reversed);
+
+                       if (!(next->object.flags & VISITED)) {
+                               sort_first_epoch(next, &stack);
+                               if (reversed) {
+                                       /*
+                                        * If we have more commits 
+                                        * to push, then the first
+                                        * push for the next parent may 
+                                        * (or may * not) represent a 
+                                        * discontinuity with respect
+                                        * to the parent currently on 
+                                        * the top of the stack.
+                                        *
+                                        * Mark it for checking here, 
+                                        * and check it with the next 
+                                        * push. See sort_first_epoch()
+                                        * for more details.
+                                        */
+                                       stack->item->object.flags |= DISCONTINUITY;
+                               }
                        }
                }