{"thread":{"id":"41965","subject":"[PATCH] log: allow --graph and --show-linear-break used together","startedAt":"2016-04-08T11:21:07Z","lastAt":"2016-04-08T17:11:14Z","messageCount":3,"participants":["Jan Kundrát","Duy Nguyen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"282946","messageId":"3305f7dc-0044-41fe-8aab-ee800535d6e9@kde.org","threadId":"41965","inReplyTo":null,"subject":"[PATCH] log: allow --graph and --show-linear-break used together","fromName":"Jan Kundrát","fromEmail":"jkt@kde.org","sentAt":"2016-04-08T11:21:07Z","receivedAt":"2016-04-08T11:21:07Z","isPatch":true,"sender":{"key":"jkt@kde.org","avatar":null},"body":"Hi,\nthis patch makes it possible to use --show-linear-break in `git log --graph \n--oneline --all`.\n\n(Please Cc me on replies, I'm not subscribed to the Git ML.)\n\nCheers,\nJan\n\n-- \nTrojitá, a fast Qt IMAP e-mail client -- http://trojita.flaska.net/\n\nFrom 1ac6bb7c31652835d3d046c82e423f0cea6e0904 Mon Sep 17 00:00:00 2001\nFrom: =?UTF-8?q?Jan=20Kundr=C3=A1t?= <jkt@kde.org>\nDate: Fri, 8 Apr 2016 13:06:31 +0200\nSubject: [PATCH] log: allow --graph and --show-linear-break used together\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\nThere was no visual break when --graph --oneline was used with several\nhistory trees with disjoint parents.\n\nThe original reasoning given in commit 1b32decef was probably that a\ngraph already conveys enough information to indicate that there's no\nparent-child relation between these two commits. However, this is not\nthe case when a single-line prettification of a log is used, in which\ncase the commits are displayed on top of each other with no space for\nthat graph line to show the separation.\n\nIt might be interesting to change the actual printing of the break_bar\nto print fewer line breaks, but this simple approach works and is IMHO\nnot that bad visually, anyway.\n\nSigned-off-by: Jan Kundrát <jkt@kde.org>\n---\n Documentation/rev-list-options.txt | 5 +++--\n revision.c                         | 4 ++--\n 2 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex 4f009d4..c5e487c 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -807,8 +807,9 @@ This implies the `--topo-order` option by default, but the\n `--date-order` option may also be specified.\n \n --show-linear-break[=<barrier>]::\n-\tWhen --graph is not used, all history branches are flattened\n-\twhich can make it hard to see that the two consecutive commits\n+\tIf the history is flattened, such as when --graph is not used\n+\tor if --graph is combined with --oneline to produce a compact\n+\tview, it can be hard to see that the two consecutive commits\n \tdo not belong to a linear branch. This option puts a barrier\n \tin between them in that case. If `<barrier>` is specified, it\n \tis the string that will be shown instead of the default one.\ndiff --git a/revision.c b/revision.c\nindex 8b2dfe3..809c43e 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1864,6 +1864,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\t   starts_with(arg, \"--show-linear-break=\")) {\n \t\tif (starts_with(arg, \"--show-linear-break=\"))\n \t\t\trevs->break_bar = xstrdup(arg + 20);\n+\t\telse if (revs->graph)\n+\t\t\trevs->break_bar = \"  ..........\\n\";\n \t\telse\n \t\t\trevs->break_bar = \"                    ..........\";\n \t\trevs->track_linear = 1;\n@@ -1993,8 +1995,6 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\t\tunkv[(*unkc)++] = arg;\n \t\treturn opts;\n \t}\n-\tif (revs->graph && revs->track_linear)\n-\t\tdie(\"--show-linear-break and --graph are incompatible\");\n \n \treturn 1;\n }\n-- \n2.7.3\n\n"},{"id":"282954","messageId":"20160408124338.GA30174@lanh","threadId":"41965","inReplyTo":"3305f7dc-0044-41fe-8aab-ee800535d6e9@kde.org","subject":"Re: [PATCH] log: allow --graph and --show-linear-break used together","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2016-04-08T12:43:38Z","receivedAt":"2016-04-08T12:43:38Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Apr 08, 2016 at 01:21:07PM +0200, Jan Kundrát wrote:\n> From 1ac6bb7c31652835d3d046c82e423f0cea6e0904 Mon Sep 17 00:00:00 2001\n> From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= <jkt@kde.org>\n> Date: Fri, 8 Apr 2016 13:06:31 +0200\n> Subject: [PATCH] log: allow --graph and --show-linear-break used together\n> MIME-Version: 1.0\n> Content-Type: text/plain; charset=UTF-8\n> Content-Transfer-Encoding: 8bit\n> \n> There was no visual break when --graph --oneline was used with several\n> history trees with disjoint parents.\n> \n> The original reasoning given in commit 1b32decef was probably that a\n> graph already conveys enough information to indicate that there's no\n> parent-child relation between these two commits. However, this is not\n> the case when a single-line prettification of a log is used, in which\n> case the commits are displayed on top of each other with no space for\n> that graph line to show the separation.\n> \n> It might be interesting to change the actual printing of the break_bar\n> to print fewer line breaks, but this simple approach works and is IMHO\n> not that bad visually, anyway.\n\nHow about something like this? It does not break the graph, which is\nprobably better visually, although some may say breaking the graph\n_is_ better in this particular case.\n\nI also try to fix the extra blank lines in --oneline mode (with or\nwithout --graph). That's definitely an improvement.\n\n-- 8< --\ndiff --git a/graph.c b/graph.c\nindex 1350bdd..deafdd4 100644\n--- a/graph.c\n+++ b/graph.c\n@@ -1226,6 +1226,14 @@ void graph_show_padding(struct git_graph *graph)\n \tstrbuf_release(&msgbuf);\n }\n \n+void graph_show_vertical_bars(struct git_graph *graph)\n+{\n+\tint saved_width = graph->width;\n+\tgraph->width = 0;\t/* no extra padding */\n+\tgraph_show_padding(graph);\n+\tgraph->width = saved_width;\n+}\n+\n int graph_show_remainder(struct git_graph *graph)\n {\n \tstruct strbuf msgbuf = STRBUF_INIT;\ndiff --git a/graph.h b/graph.h\nindex 0be62bd..5e55425 100644\n--- a/graph.h\n+++ b/graph.h\n@@ -91,6 +91,8 @@ void graph_show_oneline(struct git_graph *graph);\n  */\n void graph_show_padding(struct git_graph *graph);\n \n+void graph_show_vertical_bars(struct git_graph *graph);\n+\n /*\n  * If the graph is non-NULL, print the rest of the history graph for this\n  * commit to stdout.  Does not print a terminating newline on the last line.\ndiff --git a/log-tree.c b/log-tree.c\nindex 60f9839..61d7cbd 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -858,6 +858,22 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log\n \treturn showed_log;\n }\n \n+static void show_break_bar(struct rev_info *opt)\n+{\n+\tif (opt->graph) {\n+\t\tif (opt->commit_format != CMIT_FMT_ONELINE) {\n+\t\t\tgraph_show_vertical_bars(opt->graph);\n+\t\t\tputchar('\\n');\n+\t\t}\n+\t\tgraph_show_vertical_bars(opt->graph);\n+\t\tprintf(\"%s\\n\", opt->break_bar);\n+\t} else {\n+\t\tif (opt->commit_format != CMIT_FMT_ONELINE)\n+\t\t\tputchar('\\n');\n+\t\tprintf(\"%s\\n\", opt->break_bar);\n+\t}\n+}\n+\n int log_tree_commit(struct rev_info *opt, struct commit *commit)\n {\n \tstruct log_info log;\n@@ -871,7 +887,7 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)\n \t\treturn line_log_print(opt, commit);\n \n \tif (opt->track_linear && !opt->linear && !opt->reverse_output_stage)\n-\t\tprintf(\"\\n%s\\n\", opt->break_bar);\n+\t\tshow_break_bar(opt);\n \tshown = log_tree_diff(opt, commit, &log);\n \tif (!shown && opt->loginfo && opt->always_show_header) {\n \t\tlog.parent = NULL;\n@@ -879,7 +895,7 @@ int log_tree_commit(struct rev_info *opt, struct commit *commit)\n \t\tshown = 1;\n \t}\n \tif (opt->track_linear && !opt->linear && opt->reverse_output_stage)\n-\t\tprintf(\"\\n%s\\n\", opt->break_bar);\n+\t\tshow_break_bar(opt);\n \topt->loginfo = NULL;\n \tmaybe_flush_or_die(stdout, \"stdout\");\n \treturn shown;\n-- 8< --\n\n\n> \n> Signed-off-by: Jan Kundr??t <jkt@kde.org>\n> ---\n>  Documentation/rev-list-options.txt | 5 +++--\n>  revision.c                         | 4 ++--\n>  2 files changed, 5 insertions(+), 4 deletions(-)\n> \n> diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\n> index 4f009d4..c5e487c 100644\n> --- a/Documentation/rev-list-options.txt\n> +++ b/Documentation/rev-list-options.txt\n> @@ -807,8 +807,9 @@ This implies the `--topo-order` option by default, but the\n>  `--date-order` option may also be specified.\n>  \n>  --show-linear-break[=<barrier>]::\n> -\tWhen --graph is not used, all history branches are flattened\n> -\twhich can make it hard to see that the two consecutive commits\n> +\tIf the history is flattened, such as when --graph is not used\n> +\tor if --graph is combined with --oneline to produce a compact\n> +\tview, it can be hard to see that the two consecutive commits\n>  \tdo not belong to a linear branch. This option puts a barrier\n>  \tin between them in that case. If `<barrier>` is specified, it\n>  \tis the string that will be shown instead of the default one.\n> diff --git a/revision.c b/revision.c\n> index 8b2dfe3..809c43e 100644\n> --- a/revision.c\n> +++ b/revision.c\n> @@ -1864,6 +1864,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n>  \t\t   starts_with(arg, \"--show-linear-break=\")) {\n>  \t\tif (starts_with(arg, \"--show-linear-break=\"))\n>  \t\t\trevs->break_bar = xstrdup(arg + 20);\n> +\t\telse if (revs->graph)\n> +\t\t\trevs->break_bar = \"  ..........\\n\";\n>  \t\telse\n>  \t\t\trevs->break_bar = \"                    ..........\";\n>  \t\trevs->track_linear = 1;\n> @@ -1993,8 +1995,6 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n>  \t\t\tunkv[(*unkc)++] = arg;\n>  \t\treturn opts;\n>  \t}\n> -\tif (revs->graph && revs->track_linear)\n> -\t\tdie(\"--show-linear-break and --graph are incompatible\");\n>  \n>  \treturn 1;\n>  }\n> -- \n> 2.7.3\n> \n"},{"id":"282968","messageId":"xmqqzit4vxe5.fsf@gitster.mtv.corp.google.com","threadId":"41965","inReplyTo":"3305f7dc-0044-41fe-8aab-ee800535d6e9@kde.org","subject":"Re: [PATCH] log: allow --graph and --show-linear-break used together","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-08T17:11:14Z","receivedAt":"2016-04-08T17:11:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jan Kundrát <jkt@kde.org> writes:\n\n> this patch makes it possible to use --show-linear-break in `git log\n> --graph --oneline --all`.\n\nYou have multiple roots, just like we would show the histories like\nthis:\n\n    *     A\n    |\\\n    | *   B\n    | *   C (root)\n    *    D\n    *    E (another root)\n\nteaching the \"graph\" code to show the history like this:\n\n    *     B\n    *     C (root)\n      * D\n     /\n    *   E (another root)\n\nwould be more beneficial than using --show-linear-break and chopping\nthe graph, wouldn't it?\n"}]}