Code

Merge branch 'sv/first-parent'
authorJunio C Hamano <gitster@pobox.com>
Wed, 21 May 2008 21:15:52 +0000 (14:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 May 2008 21:15:52 +0000 (14:15 -0700)
* sv/first-parent:
  revision.c: really honor --first-parent
  Simplify and fix --first-parent implementation

1  2 
revision.c

diff --combined revision.c
index c947e0fa1ea070370a4ad4c4d699b4d6ce022b61,6f5b548a32cd406523cf1aaca8eaa6147bd55b16..7142cf96cde81377522e49de5f102a25eaec2d54
@@@ -6,7 -6,6 +6,7 @@@
  #include "diff.h"
  #include "refs.h"
  #include "revision.h"
 +#include "graph.h"
  #include "grep.h"
  #include "reflog-walk.h"
  #include "patch-ids.h"
@@@ -416,7 -415,6 +416,6 @@@ static int add_parents_to_list(struct r
  {
        struct commit_list *parent = commit->parents;
        unsigned left_flag;
-       int add, rest;
  
        if (commit->object.flags & ADDED)
                return 0;
  
        left_flag = (commit->object.flags & SYMMETRIC_LEFT);
  
-       rest = !revs->first_parent_only;
-       for (parent = commit->parents, add = 1; parent; add = rest) {
+       for (parent = commit->parents; parent; parent = parent->next) {
                struct commit *p = parent->item;
  
-               parent = parent->next;
                if (parse_commit(p) < 0)
                        return -1;
                p->object.flags |= left_flag;
-               if (p->object.flags & SEEN)
-                       continue;
-               p->object.flags |= SEEN;
-               if (add)
+               if (!(p->object.flags & SEEN)) {
+                       p->object.flags |= SEEN;
                        insert_by_date(p, list);
+               }
+               if(revs->first_parent_only)
+                       break;
        }
        return 0;
  }
@@@ -1106,8 -1103,7 +1104,8 @@@ int setup_revisions(int argc, const cha
                                }
                        }
                        if (!strcmp(arg, "--parents")) {
 -                              revs->parents = 1;
 +                              revs->rewrite_parents = 1;
 +                              revs->print_parents = 1;
                                continue;
                        }
                        if (!strcmp(arg, "--dense")) {
                                get_commit_format(arg+8, revs);
                                continue;
                        }
 +                      if (!prefixcmp(arg, "--graph")) {
 +                              revs->topo_order = 1;
 +                              revs->rewrite_parents = 1;
 +                              revs->graph = graph_init();
 +                              continue;
 +                      }
                        if (!strcmp(arg, "--root")) {
                                revs->show_root_diff = 1;
                                continue;
        if (revs->reverse && revs->reflog_info)
                die("cannot combine --reverse with --walk-reflogs");
  
 +      /*
 +       * Limitations on the graph functionality
 +       */
 +      if (revs->reverse && revs->graph)
 +              die("cannot combine --reverse with --graph");
 +
 +      if (revs->reflog_info && revs->graph)
 +              die("cannot combine --walk-reflogs with --graph");
 +
        return left;
  }
  
@@@ -1541,13 -1522,13 +1539,13 @@@ enum commit_action simplify_commit(stru
                /* Commit without changes? */
                if (commit->object.flags & TREESAME) {
                        /* drop merges unless we want parenthood */
 -                      if (!revs->parents)
 +                      if (!revs->rewrite_parents)
                                return commit_ignore;
                        /* non-merge - always ignore it */
                        if (!commit->parents || !commit->parents->next)
                                return commit_ignore;
                }
 -              if (revs->parents && rewrite_parents(revs, commit) < 0)
 +              if (revs->rewrite_parents && rewrite_parents(revs, commit) < 0)
                        return commit_error;
        }
        return commit_show;
@@@ -1614,7 -1595,7 +1612,7 @@@ static void gc_boundary(struct object_a
        }
  }
  
 -struct commit *get_revision(struct rev_info *revs)
 +static struct commit *get_revision_internal(struct rev_info *revs)
  {
        struct commit *c = NULL;
        struct commit_list *l;
  
        return c;
  }
 +
 +struct commit *get_revision(struct rev_info *revs)
 +{
 +      struct commit *c = get_revision_internal(revs);
 +      if (c && revs->graph)
 +              graph_update(revs->graph, c);
 +      return c;
 +}