{"thread":{"id":"13612","subject":"[PATCH] log --graph: draw '>' and '<' with --left-right","startedAt":"2008-05-22T11:36:20Z","lastAt":"2008-05-25T07:07:21Z","messageCount":6,"participants":["Johannes Schindelin","Sverre Rabbelier","Junio C Hamano","Adam Simpkins"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"77456","messageId":"alpine.DEB.1.00.0805221235430.30431@racer","threadId":"13612","inReplyTo":null,"subject":"[PATCH] log --graph: draw '>' and '<' with --left-right","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-05-22T11:36:20Z","receivedAt":"2008-05-22T11:36:20Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Documentation/technical/api-history-graph.txt |    2 +-\n graph.c                                       |   16 ++++++++++++++--\n graph.h                                       |    2 +-\n revision.c                                    |    2 +-\n 4 files changed, 17 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/technical/api-history-graph.txt b/Documentation/technical/api-history-graph.txt\nindex ce1c08e..e955979 100644\n--- a/Documentation/technical/api-history-graph.txt\n+++ b/Documentation/technical/api-history-graph.txt\n@@ -115,7 +115,7 @@ Sample usage\n \n ------------\n struct commit *commit;\n-struct git_graph *graph = graph_init();\n+struct git_graph *graph = graph_init(opts);\n \n while ((commit = get_revision(opts)) != NULL) {\n \tgraph_update(graph, commit);\ndiff --git a/graph.c b/graph.c\nindex 9d6ed30..85a9ba0 100644\n--- a/graph.c\n+++ b/graph.c\n@@ -55,6 +55,10 @@ struct git_graph {\n \t */\n \tstruct commit *commit;\n \t/*\n+\t * For the --left-right option.\n+\t */\n+\tstruct rev_info *revs;\n+\t/*\n \t * The number of parents this commit has.\n \t * (Stored so we don't have to walk over them each time we need\n \t * this number)\n@@ -125,10 +129,11 @@ struct git_graph {\n \tint *new_mapping;\n };\n \n-struct git_graph *graph_init(void)\n+struct git_graph *graph_init(struct rev_info *opt)\n {\n \tstruct git_graph *graph = xmalloc(sizeof(struct git_graph));\n \tgraph->commit = NULL;\n+\tgraph->revs = opt;\n \tgraph->num_parents = 0;\n \tgraph->expansion_row = 0;\n \tgraph->state = GRAPH_PADDING;\n@@ -540,7 +545,14 @@ void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb)\n \n \t\tif (col_commit == graph->commit) {\n \t\t\tseen_this = 1;\n-\t\t\tif (graph->num_parents > 1)\n+\t\t\tif (graph->revs && graph->revs->left_right) {\n+\t\t\t\tif (graph->commit->object.flags\n+\t\t\t\t\t\t& SYMMETRIC_LEFT)\n+\t\t\t\t\tstrbuf_addch(sb, '<');\n+\t\t\t\telse\n+\t\t\t\t\tstrbuf_addch(sb, '>');\n+\t\t\t}\n+\t\t\telse if (graph->num_parents > 1)\n \t\t\t\tstrbuf_addch(sb, 'M');\n \t\t\telse\n \t\t\t\tstrbuf_addch(sb, '*');\ndiff --git a/graph.h b/graph.h\nindex a7748a5..eab4e3d 100644\n--- a/graph.h\n+++ b/graph.h\n@@ -8,7 +8,7 @@ struct git_graph;\n  * Create a new struct git_graph.\n  * The graph should be freed with graph_release() when no longer needed.\n  */\n-struct git_graph *graph_init();\n+struct git_graph *graph_init(struct rev_info *opt);\n \n /*\n  * Destroy a struct git_graph and free associated memory.\ndiff --git a/revision.c b/revision.c\nindex 39ceef0..ce0f1ac 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1206,7 +1206,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t\tif (!prefixcmp(arg, \"--graph\")) {\n \t\t\t\trevs->topo_order = 1;\n \t\t\t\trevs->rewrite_parents = 1;\n-\t\t\t\trevs->graph = graph_init();\n+\t\t\t\trevs->graph = graph_init(revs);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--root\")) {\n-- \n1.5.5.1.498.gaaa3c0\n"},{"id":"77461","messageId":"alpine.DEB.1.00.0805221344360.30431@racer","threadId":"13612","inReplyTo":"alpine.DEB.1.00.0805221235430.30431@racer","subject":"Re: [PATCH] log --graph: draw '>' and '<' with --left-right","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-05-22T12:47:23Z","receivedAt":"2008-05-22T12:47:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 22 May 2008, Johannes Schindelin wrote:\n\n> \n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nSverre just notified me that the commit message is not brilliant.  How \nabout this:\n\n-- snip --\nWhen calling \"git log --left-right <branch1>...<branch2>\", a single \"<\" or \n\">\" is shown in front of the commit line, to indicate which branch1 this \ncommit comes from, branch1 or branch2.\n\nHowever, it is easy to miss in the output of \"git log --graph ...\", since \nthe graph still has \"*\" for regular commits and \"M\" for merge commits.  So \nimitate gitk, and show the \"<\" and \">\" characters in the graph, too, \ninstead of \"*\" (or \"M\").\n-- snap --\n\nThanks,\nDscho\n"},{"id":"77471","messageId":"bd6139dc0805220614l2504ca0bk432d3101d853b28c@mail.gmail.com","threadId":"13612","inReplyTo":"alpine.DEB.1.00.0805221344360.30431@racer","subject":"Re: [PATCH] log --graph: draw '>' and '<' with --left-right","fromName":"Sverre Rabbelier","fromEmail":"alturin@gmail.com","sentAt":"2008-05-22T13:14:13Z","receivedAt":"2008-05-22T13:14:13Z","isPatch":true,"sender":{"key":"alturin@gmail.com","avatar":null},"body":"On Thu, May 22, 2008 at 2:47 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Sverre just notified me that the commit message is not brilliant.  How\n> about this:\n>\n> -- snip --\n> When calling \"git log --left-right <branch1>...<branch2>\", a single \"<\" or\n> \">\" is shown in front of the commit line, to indicate which branch1 this\n> commit comes from, branch1 or branch2.\n>\n> However, it is easy to miss in the output of \"git log --graph ...\", since\n> the graph still has \"*\" for regular commits and \"M\" for merge commits.  So\n> imitate gitk, and show the \"<\" and \">\" characters in the graph, too,\n> instead of \"*\" (or \"M\").\n> -- snap --\n\nI admit that I didn't know how gitk does things, but yeah, this is a\nlot more explanatory and makes sense :).\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"77694","messageId":"7v63t3j6mn.fsf@gitster.siamese.dyndns.org","threadId":"13612","inReplyTo":"alpine.DEB.1.00.0805221344360.30431@racer","subject":"Re: [PATCH] log --graph: draw '>' and '<' with --left-right","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-05-25T05:27:12Z","receivedAt":"2008-05-25T05:27:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> When calling \"git log --left-right <branch1>...<branch2>\", a single \"<\" or \n> \">\" is shown in front of the commit line, to indicate which branch1 this \n> commit comes from, branch1 or branch2.\n>\n> However, it is easy to miss in the output of \"git log --graph ...\", since \n> the graph still has \"*\" for regular commits and \"M\" for merge commits.  So \n> imitate gitk, and show the \"<\" and \">\" characters in the graph, too, \n> instead of \"*\" (or \"M\").\n\nThis certainly makes it more visible which one is left and which one is\nright:\n\n    < commit <205ffa9...\n    | Author: Gustaf Hendeby <hendeby@isy.liu.se>\n    |\n    |     Make git add -n and git -u -n output consistent\n    |\n    < commit <38ed1d8...\n    | Author: Junio C Hamano <gitster@pobox.com>\n    |\n    |     \"git-add -n -u\" should not add but just report\n    ...\n\nthan\n\n    * commit <205ffa9...\n    | Author: Gustaf Hendeby <hendeby@isy.liu.se>\n    |\n    |     Make git add -n and git -u -n output consistent\n    |\n    * commit <38ed1d8...\n    | Author: Junio C Hamano <gitster@pobox.com>\n    |\n    |     \"git-add -n -u\" should not add but just report\n    |\n    ...\n\nBut is it just me who now finds the original marker redundant and ugly?\nIOW, I wonder if it is better to show this:\n\n    < commit 205ffa9...\n    | Author: Gustaf Hendeby <hendeby@isy.liu.se>\n    |\n    |     Make git add -n and git -u -n output consistent\n    |\n    < commit 38ed1d8...\n    | Author: Junio C Hamano <gitster@pobox.com>\n    |\n    |     \"git-add -n -u\" should not add but just report\n    ...\n\nThis is with --pretty=short, --pretty=oneline makes the issue even more\nobvious.\n\nAdam?\n"},{"id":"77696","messageId":"20080525064324.GA16827@adamsimpkins.net","threadId":"13612","inReplyTo":"7v63t3j6mn.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] log --graph: draw '>' and '<' with --left-right","fromName":"Adam Simpkins","fromEmail":"adam@adamsimpkins.net","sentAt":"2008-05-25T06:43:25Z","receivedAt":"2008-05-25T06:43:25Z","isPatch":true,"sender":{"key":"adam@adamsimpkins.net","avatar":"https://gravatar.com/avatar/d3fd2c0b3e2d2136b56e95726ee03227bee4eb562f627dcd3ebca0623fa05054?d=mp&s=160"},"body":"On Sat, May 24, 2008 at 10:27:12PM -0700, Junio C Hamano wrote:\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > When calling \"git log --left-right <branch1>...<branch2>\", a single \"<\" or \n> > \">\" is shown in front of the commit line, to indicate which branch1 this \n> > commit comes from, branch1 or branch2.\n> >\n> > However, it is easy to miss in the output of \"git log --graph ...\", since \n> > the graph still has \"*\" for regular commits and \"M\" for merge commits.  So \n> > imitate gitk, and show the \"<\" and \">\" characters in the graph, too, \n> > instead of \"*\" (or \"M\").\n> \n> This certainly makes it more visible which one is left and which one is\n> right:\n>\n> ...\n> \n> But is it just me who now finds the original marker redundant and ugly?\n> IOW, I wonder if it is better to show this:\n> \n>     < commit 205ffa9...\n>     | Author: Gustaf Hendeby <hendeby@isy.liu.se>\n>     |\n>     |     Make git add -n and git -u -n output consistent\n>     |\n>     < commit 38ed1d8...\n>     | Author: Junio C Hamano <gitster@pobox.com>\n>     |\n>     |     \"git-add -n -u\" should not add but just report\n>     ...\n> \n> This is with --pretty=short, --pretty=oneline makes the issue even more\n> obvious.\n\nYes, I agree that the original marker is now redundant, and it looks\nbetter without it.\n\nMy recent patch to fix the \"log --graph --boundary\" behavior also\nchanges the graph code to print boundary commits as 'o' instead of\n'*'.  We could probably also remove the original '-' prefix for\nboundary commits when the graph output is enabled.\n\nI was looking at the code, and noticed that it also outputs a '^'\nprefix for non-boundary commits that are marked UNINTERESTING.  In\nwhat situations will get_revision() return a commit that is\nUNINTERESTING but not BOUNDARY?  I'm asking since the graph code\ncurrently treats these commits as uninteresting, and won't print\nbranch lines for them.  If there are situations where these commits\nare included in the log output, the graph code probably needs to be\nupdated to handle it.\n\n-- \nAdam Simpkins\nadam@adamsimpkins.net\n"},{"id":"77698","messageId":"1211699241-19201-1-git-send-email-adam@adamsimpkins.net","threadId":"13612","inReplyTo":"20080525064324.GA16827@adamsimpkins.net","subject":"[PATCH] log and rev-list: don't print extra prefixes already shown in the graph","fromName":"Adam Simpkins","fromEmail":"adam@adamsimpkins.net","sentAt":"2008-05-25T07:07:21Z","receivedAt":"2008-05-25T07:07:21Z","isPatch":true,"sender":{"key":"adam@adamsimpkins.net","avatar":"https://gravatar.com/avatar/d3fd2c0b3e2d2136b56e95726ee03227bee4eb562f627dcd3ebca0623fa05054?d=mp&s=160"},"body":"With the --graph option, the graph already outputs 'o' instead of '*'\nfor boundary commits, and '<' or '>' when --left-right is specified.\nThe extra -/</> prefix in front of the commit itself isn't needed.\n\n(This change also disables the '^' prefix for UNINTERESTING commits.\nThe graph code currently doesn't print anything special for these\ncommits, since it assumes no UNINTERESTING, non-BOUNDARY commits are\ndisplayed.  This is potentially a bug if UNINTERESTING non-BOUNDARY\ncommits can actually be displayed via some code path.)\n\nSigned-off-by: Adam Simpkins <adam@adamsimpkins.net>\n---\n\nHere's simple patch to remove the redundant </>/- prefix in the log\nmessage.  As the commit message mentions, I'm not sure if it's doing the\nright thing with respect to UNINTERESTING commits, though.\n\n builtin-rev-list.c |   21 ++++++++++++---------\n log-tree.c         |   41 +++++++++++++++++++++++------------------\n 2 files changed, 35 insertions(+), 27 deletions(-)\n\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex 54d55cc..b474527 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -65,15 +65,18 @@ static void show_commit(struct commit *commit)\n \t\tprintf(\"%lu \", commit->date);\n \tif (header_prefix)\n \t\tfputs(header_prefix, stdout);\n-\tif (commit->object.flags & BOUNDARY)\n-\t\tputchar('-');\n-\telse if (commit->object.flags & UNINTERESTING)\n-\t\tputchar('^');\n-\telse if (revs.left_right) {\n-\t\tif (commit->object.flags & SYMMETRIC_LEFT)\n-\t\t\tputchar('<');\n-\t\telse\n-\t\t\tputchar('>');\n+\n+\tif (!revs.graph) {\n+\t\tif (commit->object.flags & BOUNDARY)\n+\t\t\tputchar('-');\n+\t\telse if (commit->object.flags & UNINTERESTING)\n+\t\t\tputchar('^');\n+\t\telse if (revs.left_right) {\n+\t\t\tif (commit->object.flags & SYMMETRIC_LEFT)\n+\t\t\t\tputchar('<');\n+\t\t\telse\n+\t\t\t\tputchar('>');\n+\t\t}\n \t}\n \tif (revs.abbrev_commit && revs.abbrev)\n \t\tfputs(find_unique_abbrev(commit->object.sha1, revs.abbrev),\ndiff --git a/log-tree.c b/log-tree.c\nindex 1474d1f..5505606 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -228,15 +228,17 @@ void show_log(struct rev_info *opt)\n \tif (!opt->verbose_header) {\n \t\tgraph_show_commit(opt->graph);\n \n-\t\tif (commit->object.flags & BOUNDARY)\n-\t\t\tputchar('-');\n-\t\telse if (commit->object.flags & UNINTERESTING)\n-\t\t\tputchar('^');\n-\t\telse if (opt->left_right) {\n-\t\t\tif (commit->object.flags & SYMMETRIC_LEFT)\n-\t\t\t\tputchar('<');\n-\t\t\telse\n-\t\t\t\tputchar('>');\n+\t\tif (!opt->graph) {\n+\t\t\tif (commit->object.flags & BOUNDARY)\n+\t\t\t\tputchar('-');\n+\t\t\telse if (commit->object.flags & UNINTERESTING)\n+\t\t\t\tputchar('^');\n+\t\t\telse if (opt->left_right) {\n+\t\t\t\tif (commit->object.flags & SYMMETRIC_LEFT)\n+\t\t\t\t\tputchar('<');\n+\t\t\t\telse\n+\t\t\t\t\tputchar('>');\n+\t\t\t}\n \t\t}\n \t\tfputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);\n \t\tif (opt->print_parents)\n@@ -293,15 +295,18 @@ void show_log(struct rev_info *opt)\n \t\tfputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);\n \t\tif (opt->commit_format != CMIT_FMT_ONELINE)\n \t\t\tfputs(\"commit \", stdout);\n-\t\tif (commit->object.flags & BOUNDARY)\n-\t\t\tputchar('-');\n-\t\telse if (commit->object.flags & UNINTERESTING)\n-\t\t\tputchar('^');\n-\t\telse if (opt->left_right) {\n-\t\t\tif (commit->object.flags & SYMMETRIC_LEFT)\n-\t\t\t\tputchar('<');\n-\t\t\telse\n-\t\t\t\tputchar('>');\n+\n+\t\tif (!opt->graph) {\n+\t\t\tif (commit->object.flags & BOUNDARY)\n+\t\t\t\tputchar('-');\n+\t\t\telse if (commit->object.flags & UNINTERESTING)\n+\t\t\t\tputchar('^');\n+\t\t\telse if (opt->left_right) {\n+\t\t\t\tif (commit->object.flags & SYMMETRIC_LEFT)\n+\t\t\t\t\tputchar('<');\n+\t\t\t\telse\n+\t\t\t\t\tputchar('>');\n+\t\t\t}\n \t\t}\n \t\tfputs(diff_unique_abbrev(commit->object.sha1, abbrev_commit),\n \t\t      stdout);\n-- \n1.5.5.1.383.g8c56f.dirty\n"}]}