Merge branch 'as/maint-graph-interesting-fix'
authorJunio C Hamano <gitster@pobox.com>
Thu, 27 Aug 2009 23:59:56 +0000 (16:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Aug 2009 23:59:56 +0000 (16:59 -0700)
* as/maint-graph-interesting-fix:
Add tests for rev-list --graph with options that simplify history
graph API: fix bug in graph_is_interesting()

1  2 
graph.c
revision.c
revision.h
diff --combined graph.c
index f3226ec94a5b59372096698e216af60169d565f6,9087f658495200eb671b87711d15c05ad84089ef..6746d422a98ed010489d4ce74b26a8a4600b183e
+++ b/graph.c
@@@ -225,12 -225,7 +225,12 @@@ struct git_graph *graph_init(struct rev
        graph->num_columns = 0;
        graph->num_new_columns = 0;
        graph->mapping_size = 0;
 -      graph->default_column_color = 0;
 +      /*
 +       * Start the column color at the maximum value, since we'll
 +       * always increment it for the first commit we output.
 +       * This way we start at 0 for the first commit.
 +       */
 +      graph->default_column_color = COLUMN_COLORS_MAX - 1;
  
        /*
         * Allocate a reasonably large default number of columns
@@@ -291,9 -286,10 +291,10 @@@ static int graph_is_interesting(struct 
        }
  
        /*
-        * Uninteresting and pruned commits won't be printed
+        * Otherwise, use get_commit_action() to see if this commit is
+        * interesting
         */
-       return (commit->object.flags & (UNINTERESTING | TREESAME)) ? 0 : 1;
+       return get_commit_action(graph->revs, commit) == commit_show;
  }
  
  static struct commit_list *next_interesting_parent(struct git_graph *graph,
@@@ -504,14 -500,11 +505,14 @@@ static void graph_update_columns(struc
                             parent;
                             parent = next_interesting_parent(graph, parent)) {
                                /*
 -                               * If this is a merge increment the current
 +                               * If this is a merge, or the start of a new
 +                               * childless column, increment the current
                                 * color.
                                 */
 -                              if (graph->num_parents > 1)
 +                              if (graph->num_parents > 1 ||
 +                                  !is_commit_in_columns) {
                                        graph_increment_column_color(graph);
 +                              }
                                graph_insert_into_new_columns(graph,
                                                              parent->item,
                                                              &mapping_idx);
diff --combined revision.c
index ce24ad9a8df5589f86fb8974d3784d9a7b7f1960,efa3b7c795291fd2c337cf589977368d83d25ad6..35eca4a36185b1c5c40245748d0004fdaf0f6c00
@@@ -1052,7 -1052,7 +1052,7 @@@ static int handle_revision_opt(struct r
                revs->simplify_by_decoration = 1;
                revs->limited = 1;
                revs->prune = 1;
 -              load_ref_decorations();
 +              load_ref_decorations(DECORATE_SHORT_REFS);
        } else if (!strcmp(arg, "--date-order")) {
                revs->lifo = 0;
                revs->topo_order = 1;
@@@ -1664,7 -1664,7 +1664,7 @@@ static inline int want_ancestry(struct 
        return (revs->rewrite_parents || revs->children.name);
  }
  
- enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
+ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit)
  {
        if (commit->object.flags & SHOWN)
                return commit_ignore;
                        if (!commit->parents || !commit->parents->next)
                                return commit_ignore;
                }
-               if (want_ancestry(revs) && rewrite_parents(revs, commit) < 0)
-                       return commit_error;
        }
        return commit_show;
  }
  
+ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
+ {
+       enum commit_action action = get_commit_action(revs, commit);
+       if (action == commit_show &&
+           !revs->show_all &&
+           revs->prune && revs->dense && want_ancestry(revs)) {
+               if (rewrite_parents(revs, commit) < 0)
+                       return commit_error;
+       }
+       return action;
+ }
  static struct commit *get_revision_1(struct rev_info *revs)
  {
        if (!revs->commits)
diff --combined revision.h
index b10984b603467f2424a282d013e291d67886381e,f0b8ea7bfa205dc776a6f8e20a2032142db35f9f..9d0dddbcbc981c60fd1348cdf257c67fb9ee5f84
@@@ -15,9 -15,6 +15,9 @@@
  #define SYMMETRIC_LEFT        (1u<<8)
  #define ALL_REV_FLAGS ((1u<<9)-1)
  
 +#define DECORATE_SHORT_REFS   1
 +#define DECORATE_FULL_REFS    2
 +
  struct rev_info;
  struct log_info;
  
@@@ -168,6 -165,7 +168,7 @@@ enum commit_action 
        commit_error
  };
  
+ extern enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit);
  extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
  
  #endif