提交 6cf0a9e9 编写于 作者: J Junio C Hamano

Merge branch 'mk/maint-graph-infinity-loop' into maint

* mk/maint-graph-infinity-loop:
  graph.c: infinite loop in git whatchanged --graph -m
...@@ -33,11 +33,11 @@ The following utility functions are wrappers around `graph_next_line()` and ...@@ -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 They can all be called with a NULL graph argument, in which case no graph
output will be printed. output will be printed.
* `graph_show_commit()` calls `graph_next_line()` until it returns non-zero. * `graph_show_commit()` calls `graph_next_line()` and
This prints all graph lines up to, and including, the line containing this `graph_is_commit_finished()` until one of them return non-zero. This prints
commit. Output is printed to stdout. The last line printed does not contain all graph lines up to, and including, the line containing this commit.
a terminating newline. This should not be called if the commit line has Output is printed to stdout. The last line printed does not contain a
already been printed, or it will loop forever. terminating newline.
* `graph_show_oneline()` calls `graph_next_line()` and prints the result to * `graph_show_oneline()` calls `graph_next_line()` and prints the result to
stdout. The line printed does not contain a terminating newline. stdout. The line printed does not contain a terminating newline.
......
...@@ -1227,7 +1227,7 @@ void graph_show_commit(struct git_graph *graph) ...@@ -1227,7 +1227,7 @@ void graph_show_commit(struct git_graph *graph)
if (!graph) if (!graph)
return; return;
while (!shown_commit_line) { while (!shown_commit_line && !graph_is_commit_finished(graph)) {
shown_commit_line = graph_next_line(graph, &msgbuf); shown_commit_line = graph_next_line(graph, &msgbuf);
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout); fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
if (!shown_commit_line) if (!shown_commit_line)
......
...@@ -280,6 +280,16 @@ test_expect_success 'log --graph with merge' ' ...@@ -280,6 +280,16 @@ test_expect_success 'log --graph with merge' '
test_cmp expect actual 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 cat > expect <<\EOF
* commit master * commit master
|\ Merge: A B |\ Merge: A B
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册