Merge branch 'rs/commit-list-append'
authorJunio C Hamano <gitster@pobox.com>
Mon, 30 Apr 2012 00:51:30 +0000 (17:51 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Apr 2012 00:51:30 +0000 (17:51 -0700)
There is no need for "commit_list_reverse()" function that only invites
inefficient code.

By René Scharfe
* rs/commit-list-append:
commit: remove commit_list_reverse()
revision: append to list instead of insert and reverse
sequencer: export commit_list_append()

1  2 
revision.c
sequencer.c
diff --combined revision.c
index e0e80f13ef12c28e7f791e4c7ca9519e3c5aecc0,c1934ba3cace9e09fcf49fe92827c57c47e91473..935e7a7ba413668c95a6c3e846b9058be07f0425
@@@ -1715,21 -1715,17 +1715,21 @@@ int setup_revisions(int argc, const cha
                submodule = opt->submodule;
  
        /* First, search for "--" */
 -      seen_dashdash = 0;
 -      for (i = 1; i < argc; i++) {
 -              const char *arg = argv[i];
 -              if (strcmp(arg, "--"))
 -                      continue;
 -              argv[i] = NULL;
 -              argc = i;
 -              if (argv[i + 1])
 -                      append_prune_data(&prune_data, argv + i + 1);
 +      if (opt && opt->assume_dashdash) {
                seen_dashdash = 1;
 -              break;
 +      } else {
 +              seen_dashdash = 0;
 +              for (i = 1; i < argc; i++) {
 +                      const char *arg = argv[i];
 +                      if (strcmp(arg, "--"))
 +                              continue;
 +                      argv[i] = NULL;
 +                      argc = i;
 +                      if (argv[i + 1])
 +                              append_prune_data(&prune_data, argv + i + 1);
 +                      seen_dashdash = 1;
 +                      break;
 +              }
        }
  
        /* Second, deal with arguments and options */
@@@ -2066,15 -2062,11 +2066,16 @@@ static void set_children(struct rev_inf
        }
  }
  
 +void reset_revision_walk(void)
 +{
 +      clear_object_flags(SEEN | ADDED | SHOWN);
 +}
 +
  int prepare_revision_walk(struct rev_info *revs)
  {
        int nr = revs->pending.nr;
        struct object_array_entry *e, *list;
+       struct commit_list **next = &revs->commits;
  
        e = list = revs->pending.objects;
        revs->pending.nr = 0;
                if (commit) {
                        if (!(commit->object.flags & SEEN)) {
                                commit->object.flags |= SEEN;
-                               commit_list_insert(commit, &revs->commits);
+                               next = commit_list_append(commit, next);
                        }
                }
                e++;
        }
-       commit_list_reverse(&revs->commits);
        commit_list_sort_by_date(&revs->commits);
        if (!revs->leak_pending)
                free(list);
diff --combined sequencer.c
index cd11e340dda2d3905df84d9187f70226affef08f,ac6c8238e51f82d186ddfefc952cb8f03d9a2eaf..81d8ace35fa51f029cf78a4710a5668277a95af6
@@@ -234,7 -234,7 +234,7 @@@ static int do_recursive_merge(struct co
  
        if (!clean) {
                int i;
 -              strbuf_addstr(msgbuf, "\nConflicts:\n\n");
 +              strbuf_addstr(msgbuf, "\nConflicts:\n");
                for (i = 0; i < active_nr;) {
                        struct cache_entry *ce = active_cache[i++];
                        if (ce_stage(ce)) {
@@@ -468,33 -468,6 +468,6 @@@ static void read_and_refresh_cache(stru
        rollback_lock_file(&index_lock);
  }
  
- /*
-  * Append a commit to the end of the commit_list.
-  *
-  * next starts by pointing to the variable that holds the head of an
-  * empty commit_list, and is updated to point to the "next" field of
-  * the last item on the list as new commits are appended.
-  *
-  * Usage example:
-  *
-  *     struct commit_list *list;
-  *     struct commit_list **next = &list;
-  *
-  *     next = commit_list_append(c1, next);
-  *     next = commit_list_append(c2, next);
-  *     assert(commit_list_count(list) == 2);
-  *     return list;
-  */
- static struct commit_list **commit_list_append(struct commit *commit,
-                                              struct commit_list **next)
- {
-       struct commit_list *new = xmalloc(sizeof(struct commit_list));
-       new->item = commit;
-       *next = new;
-       new->next = NULL;
-       return &new->next;
- }
  static int format_todo(struct strbuf *buf, struct commit_list *todo_list,
                struct replay_opts *opts)
  {