rebase: support --no-autostash
[gitweb.git] / walker.c
index b929dcc6c043cc69b07846c16fb8aeb021aa3ae3..f149371e71ebdcdbd12336aace15b0fc20f74569 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -205,7 +205,7 @@ static int mark_complete(const char *path, const unsigned char *sha1, int flag,
        struct commit *commit = lookup_commit_reference_gently(sha1, 1);
        if (commit) {
                commit->object.flags |= COMPLETE;
-               commit_list_insert_by_date(commit, &complete);
+               commit_list_insert(commit, &complete);
        }
        return 0;
 }
@@ -228,8 +228,8 @@ int walker_targets_stdin(char ***target, const char ***write_ref)
 
                if (targets >= targets_alloc) {
                        targets_alloc = targets_alloc ? targets_alloc * 2 : 64;
-                       *target = xrealloc(*target, targets_alloc * sizeof(**target));
-                       *write_ref = xrealloc(*write_ref, targets_alloc * sizeof(**write_ref));
+                       REALLOC_ARRAY(*target, targets_alloc);
+                       REALLOC_ARRAY(*write_ref, targets_alloc);
                }
                (*target)[targets] = xstrdup(tg_one);
                (*write_ref)[targets] = rf_one ? xstrdup(rf_one) : NULL;
@@ -267,8 +267,11 @@ int walker_fetch(struct walker *walker, int targets, char **target,
                        goto done;
                }
        }
-       if (!walker->get_recover)
+
+       if (!walker->get_recover) {
                for_each_ref(mark_complete, NULL);
+               commit_list_sort_by_date(&complete);
+       }
 
        for (i = 0; i < targets; i++) {
                if (interpret_target(walker, target[i], &sha1[20 * i])) {
@@ -297,14 +300,13 @@ int walker_fetch(struct walker *walker, int targets, char **target,
                strbuf_addf(&refname, "refs/%s", write_ref[i]);
                if (ref_transaction_update(transaction, refname.buf,
                                           &sha1[20 * i], NULL, 0, 0,
+                                          msg ? msg : "fetch (unknown)",
                                           &err)) {
                        error("%s", err.buf);
                        goto done;
                }
        }
-       if (ref_transaction_commit(transaction,
-                                  msg ? msg : "fetch (unknown)",
-                                  &err)) {
+       if (ref_transaction_commit(transaction, &err)) {
                error("%s", err.buf);
                goto done;
        }