{"thread":{"id":"48195","subject":"[PATCH] graph.c: log.showRootMark to indicate root commits","startedAt":"2018-04-01T20:57:28Z","lastAt":"2018-04-02T18:14:05Z","messageCount":3,"participants":["Lyubomyr Shaydariv","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"343559","messageId":"0102016283000c69-b09d1499-8a50-45a7-9f41-01be648398bc-000000@eu-west-1.amazonses.com","threadId":"48195","inReplyTo":null,"subject":"[PATCH] graph.c: log.showRootMark to indicate root commits","fromName":"Lyubomyr Shaydariv","fromEmail":"lsh.dev@ukr.net","sentAt":"2018-04-01T20:57:21Z","receivedAt":"2018-04-01T20:57:28Z","isPatch":true,"sender":{"key":"lsh.dev@ukr.net","avatar":null},"body":"When log.showRootMark is set, root commits are marked with\nthe at sign (@).\n\nWhen log.showRootMark is not set, root commits are marked with\nthe asterisk sign (*). This is the default behavior.\n\nSigned-off-by: Lyubomyr Shaydariv <lsh.dev@ukr.net>\n---\n Documentation/config.txt  |  5 +++++\n Documentation/git-log.txt |  5 +++++\n graph.c                   | 20 ++++++++++++++++++++\n t/t4202-log.sh            | 16 ++++++++++++++++\n 4 files changed, 46 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 4e0cff87f62f5..0a32357e3c625 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -2254,6 +2254,11 @@ log.showRoot::\n \tTools like linkgit:git-log[1] or linkgit:git-whatchanged[1], which\n \tnormally hide the root commit will now show it. True by default.\n \n+log.showRootMark::\n+\tIf true, the initial commit in `git log --graph` will be marked\n+\twith the at sign (`@`). Otherwise the initial commit will be\n+\tmarked with the default asterisk sign (`*`). False by default.\n+\n log.showSignature::\n \tIf true, makes linkgit:git-log[1], linkgit:git-show[1], and\n \tlinkgit:git-whatchanged[1] assume `--show-signature`.\ndiff --git a/Documentation/git-log.txt b/Documentation/git-log.txt\nindex 5437f8b0f0e66..7f5436231b6d7 100644\n--- a/Documentation/git-log.txt\n+++ b/Documentation/git-log.txt\n@@ -205,6 +205,11 @@ log.showRoot::\n \t`git log -p` output would be shown without a diff attached.\n \tThe default is `true`.\n \n+log.showRootMark::\n+\tIf true, the initial commit in `git log --graph` will be marked\n+\twith the at sign (`@`). Otherwise the initial commit will be\n+\tmarked with the default asterisk sign (`*`). False by default.\n+\n log.showSignature::\n \tIf `true`, `git log` and related commands will act as if the\n \t`--show-signature` option was passed to them.\ndiff --git a/graph.c b/graph.c\nindex e1f6d3bddb38a..d14ffec7a975c 100644\n--- a/graph.c\n+++ b/graph.c\n@@ -80,6 +80,7 @@ static void graph_show_line_prefix(const struct diff_options *diffopt)\n \n static const char **column_colors;\n static unsigned short column_colors_max;\n+static int show_root_mark;\n \n static void parse_graph_colors_config(struct argv_array *colors, const char *string)\n {\n@@ -256,6 +257,16 @@ void graph_setup_line_prefix(struct diff_options *diffopt)\n }\n \n \n+static int git_graph_config(const char *var, const char *value, void *cb)\n+{\n+\tif (!strcmp(var, \"log.showrootmark\")) {\n+\t\tshow_root_mark = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n+\n+\treturn git_default_config(var, value, cb);\n+}\n+\n struct git_graph *graph_init(struct rev_info *opt)\n {\n \tstruct git_graph *graph = xmalloc(sizeof(struct git_graph));\n@@ -276,6 +287,7 @@ struct git_graph *graph_init(struct rev_info *opt)\n \t\t\t\t\t\tcustom_colors.argc - 1);\n \t\t}\n \t}\n+\tgit_config(git_graph_config, NULL);\n \n \tgraph->commit = NULL;\n \tgraph->revs = opt;\n@@ -835,6 +847,14 @@ static void graph_output_commit_char(struct git_graph *graph, struct strbuf *sb)\n \t\treturn;\n \t}\n \n+\t/*\n+\t * If the commit has no parents, it's a root commit\n+\t */\n+\tif (show_root_mark && !graph->num_parents) {\n+\t\tstrbuf_addch(sb, '@');\n+\t\treturn;\n+\t}\n+\n \t/*\n \t * get_revision_mark() handles all other cases without assert()\n \t */\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 25b1f8cc73bc3..350e35264362f 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -455,6 +455,22 @@ test_expect_success 'simple log --graph' '\n \ttest_cmp expect actual\n '\n \n+cat > expect <<EOF\n+* Second\n+* sixth\n+* fifth\n+* fourth\n+* third\n+* second\n+@ initial\n+EOF\n+\n+test_expect_success 'simple log --graph' '\n+\ttest_config log.showRootMark true &&\n+\tgit log --graph --pretty=tformat:%s >actual &&\n+\ttest_cmp expect actual\n+'\n+\n cat > expect <<EOF\n 123 * Second\n 123 * sixth\n\n--\nhttps://github.com/git/git/pull/478\n"},{"id":"343592","messageId":"xmqqk1tpze1x.fsf@gitster-ct.c.googlers.com","threadId":"48195","inReplyTo":"0102016283000c69-b09d1499-8a50-45a7-9f41-01be648398bc-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH] graph.c: log.showRootMark to indicate root commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-04-02T17:57:46Z","receivedAt":"2018-04-02T17:57:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lyubomyr Shaydariv <lsh.dev@ukr.net> writes:\n\n> When log.showRootMark is set, root commits are marked with\n> the at sign (@).\n>\n> When log.showRootMark is not set, root commits are marked with\n> the asterisk sign (*). This is the default behavior.\n>\n> Signed-off-by: Lyubomyr Shaydariv <lsh.dev@ukr.net>\n> ---\n\nSo the idea is when you have a history like this:\n\n    R1--A---B\n              \\\n    R2--C---D---M\n\nto show \"git log --oneline --graph D B\" like\n\n        * B\n        * A\n        @ R1\n        * D\n        * C\n        @ R2\n\nbecause you cannot tell that between R1 and D there is no\nparent-child relationship otherwise?\n\nOne downside of that approach is that it is not clear how this\nfeature should interact with --left-right.  I do not think there is\na clean way to do that, unless you come up with a pair of symbols,\nnot just a single '@'.\n\nAnother way to show that there is no parent-child relationship\nbetween R1 and D is to show it like this instead:\n\n        * B\n        * A\n         \\\n          * R1\n        * D\n        * C\n        * R2\n\nand that would work well with --left-right automatically (as you\nwould just do the same thing as you would to a normal asterisk).\n"},{"id":"343595","messageId":"xmqqfu4dzdax.fsf@gitster-ct.c.googlers.com","threadId":"48195","inReplyTo":"xmqqk1tpze1x.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] graph.c: log.showRootMark to indicate root commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-04-02T18:13:58Z","receivedAt":"2018-04-02T18:14:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Lyubomyr Shaydariv <lsh.dev@ukr.net> writes:\n>\n>> When log.showRootMark is set, root commits are marked with\n>> the at sign (@).\n>>\n>> When log.showRootMark is not set, root commits are marked with\n>> the asterisk sign (*). This is the default behavior.\n>>\n>> Signed-off-by: Lyubomyr Shaydariv <lsh.dev@ukr.net>\n>> ---\n>\n> So the idea is when you have a history like this:\n> ...\n> and that would work well with --left-right automatically (as you\n> would just do the same thing as you would to a normal asterisk).\n\nThere was some discussion a while back on making root commits more\napparent in the graph view, e.g.\n\nhttps://public-inbox.org/git/1382717268-21884-1-git-send-email-milton.soares.filho@gmail.com/\n\n"}]}