@matheusbsbs / matheus-bagliano / commits / beb5af43a6
Fork 0

graph API: fix bug in graph_is_interesting()

Previously, graph_is_interesting() did not behave quite the same way as the code in get_revision(). As a result, it would sometimes think commits were uninteresting, even though get_revision() would return them. This resulted in incorrect lines in the graph output. This change creates a get_commit_action() function, which graph_is_interesting() and simplify_commit() both now use to determine if a commit will be shown. It is identical to the old simplify_commit() behavior, except that it never calls rewrite_parents(). This problem was reported by Santi Béjar. The following command would exhibit the problem before, but now works correctly: git log --graph --simplify-by-decoration --oneline v1.6.3.3 Previously git graph did not display the output for this command correctly between f29ac4f and 66996ec, among other places. Signed-off-by: Adam Simpkins <simpkins@facebook.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Adam Simpkins committed Aug 18, 2009 at 19:34 UTC beb5af43a6114b551f14bc13f1beecfe8de930d9
4 files changed +49 -5
graph.c
+3 -2
@@ -286,9 +286,10 @@ static int graph_is_interesting(struct git_graph *graph, struct commit *commit)
286 }
287
288 /*
289 - * Uninteresting and pruned commits won't be printed
289 + * Otherwise, use get_commit_action() to see if this commit is
290 + * interesting
291 */
291 - return (commit->object.flags & (UNINTERESTING | TREESAME)) ? 0 : 1;
292 + return get_commit_action(graph->revs, commit) == commit_show;
293 }
294
295 static struct commit_list *next_interesting_parent(struct git_graph *graph,
revision.c
+14 -3
@@ -1664,7 +1664,7 @@ static inline int want_ancestry(struct rev_info *revs)
1664 return (revs->rewrite_parents || revs->children.name);
1665 }
1666
1667 -enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
1667 +enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit)
1668 {
1669 if (commit->object.flags & SHOWN)
1670 return commit_ignore;
@@ -1692,12 +1692,23 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
1692 if (!commit->parents || !commit->parents->next)
1693 return commit_ignore;
1694 }
1695 - if (want_ancestry(revs) && rewrite_parents(revs, commit) < 0)
1696 - return commit_error;
1695 }
1696 return commit_show;
1697 }
1698
1699 +enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)
1700 +{
1701 + enum commit_action action = get_commit_action(revs, commit);
1702 +
1703 + if (action == commit_show &&
1704 + !revs->show_all &&
1705 + revs->prune && revs->dense && want_ancestry(revs)) {
1706 + if (rewrite_parents(revs, commit) < 0)
1707 + return commit_error;
1708 + }
1709 + return action;
1710 +}
1711 +
1712 static struct commit *get_revision_1(struct rev_info *revs)
1713 {
1714 if (!revs->commits)
revision.h
+1
@@ -165,6 +165,7 @@ enum commit_action {
165 commit_error
166 };
167
168 +extern enum commit_action get_commit_action(struct rev_info *revs, struct commit *commit);
169 extern enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit);
170
171 #endif
t/t6015-rev-list-show-all-parents.sh new
+31
@@ -0,0 +1,31 @@
1 +#!/bin/sh
2 +
3 +test_description='--show-all --parents does not rewrite TREESAME commits'
4 +
5 +. ./test-lib.sh
6 +
7 +test_expect_success 'set up --show-all --parents test' '
8 + test_commit one foo.txt &&
9 + commit1=`git rev-list -1 HEAD` &&
10 + test_commit two bar.txt &&
11 + commit2=`git rev-list -1 HEAD` &&
12 + test_commit three foo.txt &&
13 + commit3=`git rev-list -1 HEAD`
14 + '
15 +
16 +test_expect_success '--parents rewrites TREESAME parents correctly' '
17 + echo $commit3 $commit1 > expected &&
18 + echo $commit1 >> expected &&
19 + git rev-list --parents HEAD -- foo.txt > actual &&
20 + test_cmp expected actual
21 + '
22 +
23 +test_expect_success '--parents --show-all does not rewrites TREESAME parents' '
24 + echo $commit3 $commit2 > expected &&
25 + echo $commit2 $commit1 >> expected &&
26 + echo $commit1 >> expected &&
27 + git rev-list --parents --show-all HEAD -- foo.txt > actual &&
28 + test_cmp expected actual
29 + '
30 +
31 +test_done