Re: [BUG] Endless loop in git whatchanged --graph -m

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michał Kiedrowicz <michal.kiedrowicz@xxxxxxxxx> wrote:

> 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@xxxxxxxxx>
> ---
> 
> 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)

Hi, has anyone looked at this?

Michał Kiedrowicz
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]