From: Junio C Hamano Date: Thu, 27 Aug 2009 23:59:56 +0000 (-0700) Subject: Merge branch 'as/maint-graph-interesting-fix' X-Git-Tag: v1.6.5-rc0~31 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/24343c609926e0163c9956b89c010e907fe755ee?ds=inline;hp=-c Merge branch 'as/maint-graph-interesting-fix' * as/maint-graph-interesting-fix: Add tests for rev-list --graph with options that simplify history graph API: fix bug in graph_is_interesting() --- 24343c609926e0163c9956b89c010e907fe755ee diff --combined graph.c index f3226ec94a,9087f65849..6746d422a9 --- a/graph.c +++ 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 ce24ad9a8d,efa3b7c795..35eca4a361 --- a/revision.c +++ b/revision.c @@@ -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; @@@ -1692,12 -1692,23 +1692,23 @@@ 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 b10984b603,f0b8ea7bfa..9d0dddbcbc --- a/revision.h +++ b/revision.h @@@ -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