{"thread":{"id":"45077","subject":"The --name-only option for git log does not play nicely with --graph","startedAt":"2017-02-07T23:12:28Z","lastAt":"2017-02-08T20:31:48Z","messageCount":3,"participants":["Davide Del Vento","Duy Nguyen","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"311015","messageId":"CAMh-zaPdSGaDvQSiWx0p7zUmfDAFDWUyHkY4BTs=j85Ue65XnA@mail.gmail.com","threadId":"45077","inReplyTo":null,"subject":"The --name-only option for git log does not play nicely with --graph","fromName":"Davide Del Vento","fromEmail":"ddvento@ucar.edu","sentAt":"2017-02-07T23:11:35Z","receivedAt":"2017-02-07T23:12:28Z","isPatch":false,"sender":{"key":"ddvento@ucar.edu","avatar":null},"body":"`git log --graph  --name-only` works fine, but the name is not\nproperly indented as it is for `git log --graph  --name-status`\n\nI tested this in git v1.9.1 the only one I have access at the moment\n\nRegards,\nDavide Del Vento,\nNCAR Computational & Information Services Laboratory\n"},{"id":"311039","messageId":"CACsJy8BmxpTW5pCLNEQa9sm8teU0O+_Xu+td+uh1K0Bn=yu=yw@mail.gmail.com","threadId":"45077","inReplyTo":"CAMh-zaPdSGaDvQSiWx0p7zUmfDAFDWUyHkY4BTs=j85Ue65XnA@mail.gmail.com","subject":"Re: The --name-only option for git log does not play nicely with --graph","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-02-08T06:24:34Z","receivedAt":"2017-02-08T06:25:11Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Feb 8, 2017 at 6:11 AM, Davide Del Vento <ddvento@ucar.edu> wrote:\n> `git log --graph  --name-only` works fine, but the name is not\n> properly indented as it is for `git log --graph  --name-status`\n>\n> I tested this in git v1.9.1 the only one I have access at the moment\n\nConfirmed still happens on master. --stat plays nicely with --graph\nthough, so it's probably just some small fixes somewhere in diff*.c.\n-- \nDuy\n"},{"id":"311083","messageId":"20170208203115.4rrtk2vwixyvhhhl@sigill.intra.peff.net","threadId":"45077","inReplyTo":"CACsJy8BmxpTW5pCLNEQa9sm8teU0O+_Xu+td+uh1K0Bn=yu=yw@mail.gmail.com","subject":"[PATCH] diff: print line prefix for --name-only output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-02-08T20:31:15Z","receivedAt":"2017-02-08T20:31:48Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Feb 08, 2017 at 01:24:34PM +0700, Duy Nguyen wrote:\n\n> On Wed, Feb 8, 2017 at 6:11 AM, Davide Del Vento <ddvento@ucar.edu> wrote:\n> > `git log --graph  --name-only` works fine, but the name is not\n> > properly indented as it is for `git log --graph  --name-status`\n> >\n> > I tested this in git v1.9.1 the only one I have access at the moment\n> \n> Confirmed still happens on master. --stat plays nicely with --graph\n> though, so it's probably just some small fixes somewhere in diff*.c.\n\nYep. Looks like every format except --name-only handles this correctly.\n\n-- >8 --\nSubject: diff: print line prefix for --name-only output\n\nIf you run \"git log --graph --name-only\", the pathnames are\nnot indented to go along with their matching commits (unlike\nall of the other diff formats). We need to output the line\nprefix for each item before writing it.\n\nThe tests cover both --name-status and --name-only. The\nformer actually gets this right already, because it builds\non the --raw format functions. It's only --name-only which\nuses its own code (and this fix mirrors the code in\ndiff_flush_raw()).\n\nNote that the tests don't follow our usual style of setting\nup the \"expect\" output inside the test block. This matches\nthe surrounding style, but more importantly it is easier to\nread: we don't have to worry about embedded single-quotes,\nand the leading indentation is more obvious.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n diff.c         |  1 +\n t/t4202-log.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 49 insertions(+)\n\ndiff --git a/diff.c b/diff.c\nindex d91a34490..a79f3408d 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4450,6 +4450,7 @@ static void flush_one_pair(struct diff_filepair *p, struct diff_options *opt)\n \t\tname_a = p->two->path;\n \t\tname_b = NULL;\n \t\tstrip_prefix(opt->prefix_length, &name_a, &name_b);\n+\t\tfprintf(opt->file, \"%s\", diff_line_prefix(opt));\n \t\twrite_name_quoted(name_a, opt->file, opt->line_termination);\n \t}\n }\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 08ea725de..48b55bfd2 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -1212,6 +1212,54 @@ test_expect_success 'log --line-prefix=\"*** \" --graph with diff and stats' '\n \ttest_i18ncmp expect actual.sanitized\n '\n \n+cat >expect <<-\\EOF\n+* reach\n+|\n+| A\treach.t\n+* Merge branch 'tangle'\n+*   Merge branch 'side'\n+|\\\n+| * side-2\n+|\n+|   A\t2\n+* Second\n+|\n+| A\tone\n+* sixth\n+\n+  D\ta/two\n+EOF\n+\n+test_expect_success 'log --graph with --name-status' '\n+\tgit log --graph --format=%s --name-status tangle..reach >actual &&\n+\tsanitize_output <actual >actual.sanitized &&\n+\ttest_cmp expect actual.sanitized\n+'\n+\n+cat >expect <<-\\EOF\n+* reach\n+|\n+| reach.t\n+* Merge branch 'tangle'\n+*   Merge branch 'side'\n+|\\\n+| * side-2\n+|\n+|   2\n+* Second\n+|\n+| one\n+* sixth\n+\n+  a/two\n+EOF\n+\n+test_expect_success 'log --graph with --name-only' '\n+\tgit log --graph --format=%s --name-only tangle..reach >actual &&\n+\tsanitize_output <actual >actual.sanitized &&\n+\ttest_cmp expect actual.sanitized\n+'\n+\n test_expect_success 'dotdot is a parent directory' '\n \tmkdir -p a/b &&\n \t( echo sixth && echo fifth ) >expect &&\n-- \n2.12.0.rc0.371.ga6cf8653b\n\n"}]}