Skip to content

Commit 6cf0a9e

Browse files
committed
Merge branch 'mk/maint-graph-infinity-loop' into maint
* mk/maint-graph-infinity-loop: graph.c: infinite loop in git whatchanged --graph -m
2 parents ab60f2c + 656197a commit 6cf0a9e

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

Documentation/technical/api-history-graph.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ The following utility functions are wrappers around `graph_next_line()` and
3333
They can all be called with a NULL graph argument, in which case no graph
3434
output will be printed.
3535

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

4242
* `graph_show_oneline()` calls `graph_next_line()` and prints the result to
4343
stdout. The line printed does not contain a terminating newline.

graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ void graph_show_commit(struct git_graph *graph)
12271227
if (!graph)
12281228
return;
12291229

1230-
while (!shown_commit_line) {
1230+
while (!shown_commit_line && !graph_is_commit_finished(graph)) {
12311231
shown_commit_line = graph_next_line(graph, &msgbuf);
12321232
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
12331233
if (!shown_commit_line)

t/t4202-log.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ test_expect_success 'log --graph with merge' '
280280
test_cmp expect actual
281281
'
282282

283+
test_expect_success 'log --raw --graph -m with merge' '
284+
git log --raw --graph --oneline -m master | head -n 500 >actual &&
285+
grep "initial" actual
286+
'
287+
288+
test_expect_success 'diff-tree --graph' '
289+
git diff-tree --graph master^ | head -n 500 >actual &&
290+
grep "one" actual
291+
'
292+
283293
cat > expect <<\EOF
284294
* commit master
285295
|\ Merge: A B

0 commit comments

Comments
 (0)