git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] Endless loop in git whatchanged --graph -m
@ 2009-07-24 23:45 Michał Kiedrowicz
  2009-07-29 16:32 ` Michał Kiedrowicz
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Kiedrowicz @ 2009-07-24 23:45 UTC (permalink / raw)
  To: Git Mailing List

Steps to reproduce:

	(Simple merge of two branches)

	$ mkdir a && cd a && git init

	$ echo file1 > file1
	$ git add file1 && git commit -m initial

	$ echo file1 >> file1
	$ git commit -a -m "commit on master"

	$ git checkout -b experimental HEAD^
	$ echo file2 > file2
	$ git add file2 && git commit -m "commit on experimental"

	$ git checkout master && git merge experimental 

	$ git whatchanged --graph -m
	<endless loop here>

Here is a simple patch, which solves this problem by removing constraint from
git_show_commit(). I'm not sure if this is the best solution. Maybe some upper
layer shouldn't call git_show_commit()?

Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
---

diff --git a/Documentation/technical/api-history-graph.txt b/Documentation/technical/api-history-graph.txt
index d66e61b..32d961a 100644
--- a/Documentation/technical/api-history-graph.txt
+++ b/Documentation/technical/api-history-graph.txt
@@ -36,11 +36,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.
diff --git a/graph.c b/graph.c
index e466770..049cdbc 100644
--- a/graph.c
+++ b/graph.c
@@ -1198,7 +1198,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)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-29 16:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-24 23:45 [BUG] Endless loop in git whatchanged --graph -m Michał Kiedrowicz
2009-07-29 16:32 ` Michał Kiedrowicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).