Skip to content

Commit

Permalink
Merge branch 'mk/maint-graph-infinity-loop' into maint
Browse files Browse the repository at this point in the history
* mk/maint-graph-infinity-loop:
  graph.c: infinite loop in git whatchanged --graph -m
  • Loading branch information
Junio C Hamano committed Jan 14, 2013
2 parents ab60f2c + 656197a commit 6cf0a9e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Documentation/technical/api-history-graph.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ The following utility functions are wrappers around `graph_next_line()` and
They can all be called with a NULL graph argument, in which case no graph
output will be printed.

* `graph_show_commit()` calls `graph_next_line()` until it returns non-zero.
This prints all graph lines up to, and including, the line containing this
commit. Output is printed to stdout. The last line printed does not contain
a terminating newline. This should not be called if the commit line has
already been printed, or it will loop forever.
* `graph_show_commit()` calls `graph_next_line()` and
`graph_is_commit_finished()` until one of them return non-zero. This prints
all graph lines up to, and including, the line containing this commit.
Output is printed to stdout. The last line printed does not contain a
terminating newline.

* `graph_show_oneline()` calls `graph_next_line()` and prints the result to
stdout. The line printed does not contain a terminating newline.
Expand Down
2 changes: 1 addition & 1 deletion graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ void graph_show_commit(struct git_graph *graph)
if (!graph)
return;

while (!shown_commit_line) {
while (!shown_commit_line && !graph_is_commit_finished(graph)) {
shown_commit_line = graph_next_line(graph, &msgbuf);
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
if (!shown_commit_line)
Expand Down
10 changes: 10 additions & 0 deletions t/t4202-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ test_expect_success 'log --graph with merge' '
test_cmp expect actual
'

test_expect_success 'log --raw --graph -m with merge' '
git log --raw --graph --oneline -m master | head -n 500 >actual &&
grep "initial" actual
'

test_expect_success 'diff-tree --graph' '
git diff-tree --graph master^ | head -n 500 >actual &&
grep "one" actual
'

cat > expect <<\EOF
* commit master
|\ Merge: A B
Expand Down

0 comments on commit 6cf0a9e

Please sign in to comment.