{"thread":{"id":"50049","subject":"[PATCH] log: add %S option (like --source) to log --format","startedAt":"2018-12-17T06:25:29Z","lastAt":"2018-12-19T17:09:59Z","messageCount":8,"participants":["Issac Trotts","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"365474","messageId":"CANdyxMwxPqTMfLsoK-2JT3Wf3hXZnQNCPRS04aSHzsMbYJZo-Q@mail.gmail.com","threadId":"50049","inReplyTo":null,"subject":"[PATCH] log: add %S option (like --source) to log --format","fromName":"Issac Trotts","fromEmail":"issac.trotts@gmail.com","sentAt":"2018-12-17T06:25:14Z","receivedAt":"2018-12-17T06:25:29Z","isPatch":true,"sender":{"key":"issac.trotts@gmail.com","avatar":"https://gravatar.com/avatar/44dd86aa2ea47c79d9b2a0a99b90e0ff18601855d2f05c6b84d6c432c5906721?d=mp&s=160"},"body":"Make it possible to write for example\n\n        git log --format=\"%H,%S\"\n\nwhere the %S at the end is a new placeholder that prints out the ref\n(tag/branch) for each commit.\n\nUsing %d might seem like an alternative but it only shows the ref for\nthe last commit in the branch.\n\nThis change is based on a question from Stack Overflow:\nhttps://stackoverflow.com/questions/12712775/git-get-source-information-in-format\n---\n Documentation/pretty-formats.txt |  2 ++\n builtin/log.c                    |  2 +-\n log-tree.c                       |  1 +\n pretty.c                         | 10 +++++++\n t/t4205-log-pretty-formats.sh    | 50 ++++++++++++++++++++++++++++++++\n 5 files changed, 64 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 417b638cd..acfe7e0a4 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -104,6 +104,8 @@ The placeholders are:\n\n - '%H': commit hash\n - '%h': abbreviated commit hash\n+- '%S': ref name given on the command line by which the commit was reached\n+  (like `git log --source`)\n - '%T': tree hash\n - '%t': abbreviated tree hash\n - '%P': parent hashes\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e8e51068b..a314ea2b6 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -203,7 +203,7 @@ static void cmd_log_init_finish(int argc, const\nchar **argv, const char *prefix,\n         rev->diffopt.filter || rev->diffopt.flags.follow_renames)\n         rev->always_show_header = 0;\n\n-    if (source) {\n+    if (source || (rev->pretty_given && rev->commit_format ==\nCMIT_FMT_USERFORMAT)) {\n         init_revision_sources(&revision_sources);\n         rev->sources = &revision_sources;\n     }\ndiff --git a/log-tree.c b/log-tree.c\nindex 10680c139..3cb14256e 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -700,6 +700,7 @@ void show_log(struct rev_info *opt)\n     ctx.color = opt->diffopt.use_color;\n     ctx.expand_tabs_in_log = opt->expand_tabs_in_log;\n     ctx.output_encoding = get_log_output_encoding();\n+    ctx.rev = opt;\n     if (opt->from_ident.mail_begin && opt->from_ident.name_begin)\n         ctx.from_ident = &opt->from_ident;\n     if (opt->graph)\ndiff --git a/pretty.c b/pretty.c\nindex b83a3ecd2..b1774acad 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -1084,6 +1084,7 @@ static size_t format_commit_one(struct strbuf\n*sb, /* in UTF-8 */\n     struct commit_list *p;\n     const char *arg;\n     int ch;\n+    char **slot;\n\n     /* these are independent of the commit */\n     switch (placeholder[0]) {\n@@ -1149,6 +1150,15 @@ static size_t format_commit_one(struct strbuf\n*sb, /* in UTF-8 */\n         parse_object(the_repository, &commit->object.oid);\n\n     switch (placeholder[0]) {\n+    case 'S':        /* tag/branch like --source */\n+        slot = revision_sources_at(c->pretty_ctx->rev->sources, commit);\n+        if (slot && *slot) {\n+            strbuf_addstr(sb, *slot);\n+            return 1;\n+        } else {\n+            die(_(\"failed to get info for %%S\"));\n+            return 0;\n+        }\n     case 'H':        /* commit hash */\n         strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_COMMIT));\n         strbuf_addstr(sb, oid_to_hex(&commit->object.oid));\ndiff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh\nindex 978a8a66f..7df8c3d4e 100755\n--- a/t/t4205-log-pretty-formats.sh\n+++ b/t/t4205-log-pretty-formats.sh\n@@ -621,4 +621,54 @@ test_expect_success 'trailer parsing not fooled\nby --- line' '\n     test_cmp expect actual\n '\n\n+test_expect_success 'set up %S tests' '\n+    git checkout --orphan source-a &&\n+    test_commit one &&\n+    test_commit two &&\n+    git checkout -b source-b HEAD^ &&\n+    test_commit three\n+'\n+\n+test_expect_success 'log --format=%S paints branch names' '\n+    cat >expect <<-\\EOF &&\n+    source-b\n+    source-a\n+    source-b\n+    EOF\n+    git log --format=%S source-a source-b >actual &&\n+    test_cmp expect actual\n+'\n+\n+test_expect_success 'log --format=%S paints tag names' '\n+    git tag -m tagged source-tag &&\n+    cat >expect <<-\\EOF &&\n+    source-tag\n+    source-a\n+    source-tag\n+    EOF\n+    git log --format=%S source-tag source-a >actual &&\n+    test_cmp expect actual\n+'\n+\n+test_expect_success 'log --format=%S paints symmetric ranges' '\n+    cat >expect <<-\\EOF &&\n+    source-b\n+    source-a\n+    EOF\n+    git log --format=%S source-a...source-b >actual &&\n+    test_cmp expect actual\n+'\n+\n+test_expect_success '%S in git log --format works with other\nplaceholders (part 1)' '\n+    git log --format=\"source-b %h\" source-b >expect &&\n+    git log --format=\"%S %h\" source-b >actual &&\n+    test_cmp expect actual\n+'\n+\n+test_expect_success '%S in git log --format works with other\nplaceholders (part 2)' '\n+    git log --format=\"%h source-b\" source-b >expect &&\n+    git log --format=\"%h %S\" source-b >actual &&\n+    test_cmp expect actual\n+'\n+\n test_done\n-- \n2.19.1\n"},{"id":"365475","messageId":"xmqqk1k8bitm.fsf@gitster-ct.c.googlers.com","threadId":"50049","inReplyTo":"CANdyxMwxPqTMfLsoK-2JT3Wf3hXZnQNCPRS04aSHzsMbYJZo-Q@mail.gmail.com","subject":"Re: [PATCH] log: add %S option (like --source) to log --format","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-12-17T09:31:33Z","receivedAt":"2018-12-17T09:31:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Issac Trotts <issac.trotts@gmail.com> writes:\n\n> Make it possible to write for example\n>\n>         git log --format=\"%H,%S\"\n>\n> where the %S at the end is a new placeholder that prints out the ref\n> (tag/branch) for each commit.\n>\n> Using %d might seem like an alternative but it only shows the ref for\n> the last commit in the branch.\n\nHave your sign-off here (see Documentation/SubmittingPatches),\n\nand then have a line that only has three-dashes on it,\n\nand then any other additional info like this.\n\n>\n> This change is based on a question from Stack Overflow:\n> https://stackoverflow.com/questions/12712775/git-get-source-information-in-format\n> ---\n\n\n\n\n>  Documentation/pretty-formats.txt |  2 ++\n>  builtin/log.c                    |  2 +-\n>  log-tree.c                       |  1 +\n>  pretty.c                         | 10 +++++++\n>  t/t4205-log-pretty-formats.sh    | 50 ++++++++++++++++++++++++++++++++\n>  5 files changed, 64 insertions(+), 1 deletion(-)\n>\n> diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\n> index 417b638cd..acfe7e0a4 100644\n> --- a/Documentation/pretty-formats.txt\n> +++ b/Documentation/pretty-formats.txt\n> @@ -104,6 +104,8 @@ The placeholders are:\n>\n>  - '%H': commit hash\n>  - '%h': abbreviated commit hash\n> +- '%S': ref name given on the command line by which the commit was reached\n> +  (like `git log --source`)\n\nThis looks entirely out of place, among the description of the basic\nbasic data like the object name of the commit itself, its tree, etc.\n\nDescribe this immediately after %d and %D are explained, perhaps.\n\n> diff --git a/builtin/log.c b/builtin/log.c\n> index e8e51068b..a314ea2b6 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -203,7 +203,7 @@ static void cmd_log_init_finish(int argc, const\n> char **argv, const char *prefix,\n>          rev->diffopt.filter || rev->diffopt.flags.follow_renames)\n>          rev->always_show_header = 0;\n>\n> -    if (source) {\n> +    if (source || (rev->pretty_given && rev->commit_format ==\n> CMIT_FMT_USERFORMAT)) {\n\nBroken line (you let your MUA line-wrap and corrupt your patch???)\n\n>          init_revision_sources(&revision_sources);\n>          rev->sources = &revision_sources;\n>      }\n\nThis means anybody who asks for say --format='%aN %s' pays the price\nof keeping track of each commit's source, which is unreasonable.\n\nPerhaps mimick the way how presence of %N is detected in\nuserformat_want_item() so that we do not pay the price for\ninit_display_notes() when a format that does not care about %N is\ngiven?\n\n> @@ -1149,6 +1150,15 @@ static size_t format_commit_one(struct strbuf\n> *sb, /* in UTF-8 */\n>          parse_object(the_repository, &commit->object.oid);\n>\n>      switch (placeholder[0]) {\n> +    case 'S':        /* tag/branch like --source */\n> +        slot = revision_sources_at(c->pretty_ctx->rev->sources, commit);\n> +        if (slot && *slot) {\n> +            strbuf_addstr(sb, *slot);\n> +            return 1;\n> +        } else {\n> +            die(_(\"failed to get info for %%S\"));\n> +            return 0;\n> +        }\n\nHave this next to case arms that deal with 'd' and 'D\".\n\n>      case 'H':        /* commit hash */\n>          strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_COMMIT));\n>          strbuf_addstr(sb, oid_to_hex(&commit->object.oid));\n\nThis is a tangent, but I think this existing case arm should move to\nthe previous block before parsing the commit, as %H only needs the\nobject name of the commit itself (reword the comment before that\nswitch to read from \"independent of the commit\" to \"computable\nwithout parsing the commit\")..\n"},{"id":"365483","messageId":"20181217155915.GA914@sigill.intra.peff.net","threadId":"50049","inReplyTo":"CANdyxMwxPqTMfLsoK-2JT3Wf3hXZnQNCPRS04aSHzsMbYJZo-Q@mail.gmail.com","subject":"Re: [PATCH] log: add %S option (like --source) to log --format","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-12-17T15:59:15Z","receivedAt":"2018-12-17T15:59:19Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Dec 16, 2018 at 10:25:14PM -0800, Issac Trotts wrote:\n\n> Make it possible to write for example\n> \n>         git log --format=\"%H,%S\"\n> \n> where the %S at the end is a new placeholder that prints out the ref\n> (tag/branch) for each commit.\n\nSeems like a reasonable thing to want.\n\nOne curious thing about \"--source\" is that it requires cooperation from\nthe actual traversal. So if you did:\n\n  git rev-list | git diff-tree --format=\"%H %S\"\n\nwe don't have the %S information in the latter command. I think that's\nprobably acceptable as long as it does something sane when we don't have\nthat information (e.g., replace it with an empty string). It might also\nbe worth calling out in the documentation.\n\n-Peff\n"},{"id":"365514","messageId":"CANdyxMxCe9xjkRYGyovRo4UU5A5PGRwpFbE4ej74hXJUF3_9zQ@mail.gmail.com","threadId":"50049","inReplyTo":"xmqqk1k8bitm.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH] log: add %S option (like --source) to log --format","fromName":"Issac Trotts","fromEmail":"issac.trotts@gmail.com","sentAt":"2018-12-18T03:35:43Z","receivedAt":"2018-12-18T03:35:58Z","isPatch":true,"sender":{"key":"issac.trotts@gmail.com","avatar":"https://gravatar.com/avatar/44dd86aa2ea47c79d9b2a0a99b90e0ff18601855d2f05c6b84d6c432c5906721?d=mp&s=160"},"body":"Hi Junio, thanks for your feedback. I'll submit a new patch as soon as\nI've addressed all the feedback.\n\nOn Mon, Dec 17, 2018 at 1:31 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Issac Trotts <issac.trotts@gmail.com> writes:\n>\n> > Make it possible to write for example\n> >\n> >         git log --format=\"%H,%S\"\n> >\n> > where the %S at the end is a new placeholder that prints out the ref\n> > (tag/branch) for each commit.\n> >\n> > Using %d might seem like an alternative but it only shows the ref for\n> > the last commit in the branch.\n>\n> Have your sign-off here (see Documentation/SubmittingPatches),\n\nDone.\n\n> and then have a line that only has three-dashes on it,\n>\n> and then any other additional info like this.\n\nDone.\n\n> > This change is based on a question from Stack Overflow:\n> > https://stackoverflow.com/questions/12712775/git-get-source-information-in-format\n> > ---\n>\n>\n>\n>\n> >  Documentation/pretty-formats.txt |  2 ++\n> >  builtin/log.c                    |  2 +-\n> >  log-tree.c                       |  1 +\n> >  pretty.c                         | 10 +++++++\n> >  t/t4205-log-pretty-formats.sh    | 50 ++++++++++++++++++++++++++++++++\n> >  5 files changed, 64 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\n> > index 417b638cd..acfe7e0a4 100644\n> > --- a/Documentation/pretty-formats.txt\n> > +++ b/Documentation/pretty-formats.txt\n> > @@ -104,6 +104,8 @@ The placeholders are:\n> >\n> >  - '%H': commit hash\n> >  - '%h': abbreviated commit hash\n> > +- '%S': ref name given on the command line by which the commit was reached\n> > +  (like `git log --source`)\n>\n> This looks entirely out of place, among the description of the basic\n> basic data like the object name of the commit itself, its tree, etc.\n>\n> Describe this immediately after %d and %D are explained, perhaps.\n\nDone.\n\n>\n> > diff --git a/builtin/log.c b/builtin/log.c\n> > index e8e51068b..a314ea2b6 100644\n> > --- a/builtin/log.c\n> > +++ b/builtin/log.c\n> > @@ -203,7 +203,7 @@ static void cmd_log_init_finish(int argc, const\n> > char **argv, const char *prefix,\n> >          rev->diffopt.filter || rev->diffopt.flags.follow_renames)\n> >          rev->always_show_header = 0;\n> >\n> > -    if (source) {\n> > +    if (source || (rev->pretty_given && rev->commit_format ==\n> > CMIT_FMT_USERFORMAT)) {\n>\n> Broken line (you let your MUA line-wrap and corrupt your patch???)\n\nI see. I need to use `git send-email`.\n\n>\n> >          init_revision_sources(&revision_sources);\n> >          rev->sources = &revision_sources;\n> >      }\n>\n> This means anybody who asks for say --format='%aN %s' pays the price\n> of keeping track of each commit's source, which is unreasonable.\n>\n> Perhaps mimick the way how presence of %N is detected in\n> userformat_want_item() so that we do not pay the price for\n> init_display_notes() when a format that does not care about %N is\n> given?\n\nDone.\n\n>\n> > @@ -1149,6 +1150,15 @@ static size_t format_commit_one(struct strbuf\n> > *sb, /* in UTF-8 */\n> >          parse_object(the_repository, &commit->object.oid);\n> >\n> >      switch (placeholder[0]) {\n> > +    case 'S':        /* tag/branch like --source */\n> > +        slot = revision_sources_at(c->pretty_ctx->rev->sources, commit);\n> > +        if (slot && *slot) {\n> > +            strbuf_addstr(sb, *slot);\n> > +            return 1;\n> > +        } else {\n> > +            die(_(\"failed to get info for %%S\"));\n> > +            return 0;\n> > +        }\n>\n> Have this next to case arms that deal with 'd' and 'D\".\n\nDone.\n\n>\n> >      case 'H':        /* commit hash */\n> >          strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_COMMIT));\n> >          strbuf_addstr(sb, oid_to_hex(&commit->object.oid));\n>\n> This is a tangent, but I think this existing case arm should move to\n> the previous block before parsing the commit, as %H only needs the\n> object name of the commit itself (reword the comment before that\n> switch to read from \"independent of the commit\" to \"computable\n> without parsing the commit\")..\n\nI hope it's all right if I keep my patch focused on just one thing.\n"},{"id":"365541","messageId":"CANdyxMzsf00k44TVkw+9uL4E3G_0rjYNgiMFK2o7MX83fCMPMQ@mail.gmail.com","threadId":"50049","inReplyTo":"20181217155915.GA914@sigill.intra.peff.net","subject":"Re: [PATCH] log: add %S option (like --source) to log --format","fromName":"Issac Trotts","fromEmail":"issac.trotts@gmail.com","sentAt":"2018-12-18T17:14:06Z","receivedAt":"2018-12-18T17:14:20Z","isPatch":true,"sender":{"key":"issac.trotts@gmail.com","avatar":"https://gravatar.com/avatar/44dd86aa2ea47c79d9b2a0a99b90e0ff18601855d2f05c6b84d6c432c5906721?d=mp&s=160"},"body":"Hi Peff, thanks for the feedback. I tried a variant of the command you\nshowed and it yielded a seg fault:\n```\n[ issactrotts ~/git ] ./git diff-tree -s --pretty=tformat:'%S %H %s' HEAD\nSegmentation fault: 11\n```\nI'll see if I can track it down this evening.\n\nIssac\n\nOn Mon, Dec 17, 2018 at 7:59 AM Jeff King <peff@peff.net> wrote:\n>\n> On Sun, Dec 16, 2018 at 10:25:14PM -0800, Issac Trotts wrote:\n>\n> > Make it possible to write for example\n> >\n> >         git log --format=\"%H,%S\"\n> >\n> > where the %S at the end is a new placeholder that prints out the ref\n> > (tag/branch) for each commit.\n>\n> Seems like a reasonable thing to want.\n>\n> One curious thing about \"--source\" is that it requires cooperation from\n> the actual traversal. So if you did:\n>\n>   git rev-list | git diff-tree --format=\"%H %S\"\n>\n> we don't have the %S information in the latter command. I think that's\n> probably acceptable as long as it does something sane when we don't have\n> that information (e.g., replace it with an empty string). It might also\n> be worth calling out in the documentation.\n>\n> -Peff\n"},{"id":"365562","messageId":"CANdyxMzOpRRu+B0cq5cbrmYsy47cod8N4mWrGtfOgRRgKVh+xA@mail.gmail.com","threadId":"50049","inReplyTo":"CANdyxMzsf00k44TVkw+9uL4E3G_0rjYNgiMFK2o7MX83fCMPMQ@mail.gmail.com","subject":"Re: [PATCH] log: add %S option (like --source) to log --format","fromName":"Issac Trotts","fromEmail":"issac.trotts@gmail.com","sentAt":"2018-12-19T03:47:36Z","receivedAt":"2018-12-19T03:47:51Z","isPatch":true,"sender":{"key":"issac.trotts@gmail.com","avatar":"https://gravatar.com/avatar/44dd86aa2ea47c79d9b2a0a99b90e0ff18601855d2f05c6b84d6c432c5906721?d=mp&s=160"},"body":"On Tue, Dec 18, 2018 at 9:14 AM Issac Trotts <issac.trotts@gmail.com> wrote:\n>\n> Hi Peff, thanks for the feedback. I tried a variant of the command you\n> showed and it yielded a seg fault:\n> ```\n> [ issactrotts ~/git ] ./git diff-tree -s --pretty=tformat:'%S %H %s' HEAD\n> Segmentation fault: 11\n> ```\n> I'll see if I can track it down this evening.\n\nOkay, found it. My solution is to make %S not do anything for commands\nother than `log` since `log` is the only one that has --source defined\nas far as I can tell.\n\nI'm waiting for Travis to run and will post an updated patch if\neverything looks good there.\n\n> Issac\n>\n> On Mon, Dec 17, 2018 at 7:59 AM Jeff King <peff@peff.net> wrote:\n> >\n> > On Sun, Dec 16, 2018 at 10:25:14PM -0800, Issac Trotts wrote:\n> >\n> > > Make it possible to write for example\n> > >\n> > >         git log --format=\"%H,%S\"\n> > >\n> > > where the %S at the end is a new placeholder that prints out the ref\n> > > (tag/branch) for each commit.\n> >\n> > Seems like a reasonable thing to want.\n> >\n> > One curious thing about \"--source\" is that it requires cooperation from\n> > the actual traversal. So if you did:\n> >\n> >   git rev-list | git diff-tree --format=\"%H %S\"\n> >\n> > we don't have the %S information in the latter command. I think that's\n> > probably acceptable as long as it does something sane when we don't have\n> > that information (e.g., replace it with an empty string). It might also\n> > be worth calling out in the documentation.\n> >\n> > -Peff\n"},{"id":"365566","messageId":"CANdyxMzYMc2DGC8JUE7N6Ry7iOLH09SwR5OFQ64c1vtbO388FA@mail.gmail.com","threadId":"50049","inReplyTo":"CANdyxMzOpRRu+B0cq5cbrmYsy47cod8N4mWrGtfOgRRgKVh+xA@mail.gmail.com","subject":"Re: [PATCH] log: add %S option (like --source) to log --format","fromName":"Issac Trotts","fromEmail":"issac.trotts@gmail.com","sentAt":"2018-12-19T08:07:35Z","receivedAt":"2018-12-19T08:07:51Z","isPatch":true,"sender":{"key":"issac.trotts@gmail.com","avatar":"https://gravatar.com/avatar/44dd86aa2ea47c79d9b2a0a99b90e0ff18601855d2f05c6b84d6c432c5906721?d=mp&s=160"},"body":"Travis showed one failure. I'm not sure if it's a flake.\nhttps://travis-ci.org/ijt/git/builds/469843833. Rerunning it.\n\nOn Tue, Dec 18, 2018 at 7:47 PM Issac Trotts <issac.trotts@gmail.com> wrote:\n>\n> On Tue, Dec 18, 2018 at 9:14 AM Issac Trotts <issac.trotts@gmail.com> wrote:\n> >\n> > Hi Peff, thanks for the feedback. I tried a variant of the command you\n> > showed and it yielded a seg fault:\n> > ```\n> > [ issactrotts ~/git ] ./git diff-tree -s --pretty=tformat:'%S %H %s' HEAD\n> > Segmentation fault: 11\n> > ```\n> > I'll see if I can track it down this evening.\n>\n> Okay, found it. My solution is to make %S not do anything for commands\n> other than `log` since `log` is the only one that has --source defined\n> as far as I can tell.\n>\n> I'm waiting for Travis to run and will post an updated patch if\n> everything looks good there.\n>\n> > Issac\n> >\n> > On Mon, Dec 17, 2018 at 7:59 AM Jeff King <peff@peff.net> wrote:\n> > >\n> > > On Sun, Dec 16, 2018 at 10:25:14PM -0800, Issac Trotts wrote:\n> > >\n> > > > Make it possible to write for example\n> > > >\n> > > >         git log --format=\"%H,%S\"\n> > > >\n> > > > where the %S at the end is a new placeholder that prints out the ref\n> > > > (tag/branch) for each commit.\n> > >\n> > > Seems like a reasonable thing to want.\n> > >\n> > > One curious thing about \"--source\" is that it requires cooperation from\n> > > the actual traversal. So if you did:\n> > >\n> > >   git rev-list | git diff-tree --format=\"%H %S\"\n> > >\n> > > we don't have the %S information in the latter command. I think that's\n> > > probably acceptable as long as it does something sane when we don't have\n> > > that information (e.g., replace it with an empty string). It might also\n> > > be worth calling out in the documentation.\n> > >\n> > > -Peff\n"},{"id":"365583","messageId":"CANdyxMzLRur8Y66-fOhusW+rW=gYaM5pnotRrEwb-iy7Sa29ew@mail.gmail.com","threadId":"50049","inReplyTo":"CANdyxMzYMc2DGC8JUE7N6Ry7iOLH09SwR5OFQ64c1vtbO388FA@mail.gmail.com","subject":"Re: [PATCH] log: add %S option (like --source) to log --format","fromName":"Issac Trotts","fromEmail":"issac.trotts@gmail.com","sentAt":"2018-12-19T17:09:45Z","receivedAt":"2018-12-19T17:09:59Z","isPatch":true,"sender":{"key":"issac.trotts@gmail.com","avatar":"https://gravatar.com/avatar/44dd86aa2ea47c79d9b2a0a99b90e0ff18601855d2f05c6b84d6c432c5906721?d=mp&s=160"},"body":"Looks like that was a flake. Everything passes now.\nhttps://travis-ci.org/ijt/git/builds/469843833\n\nOn Wed, Dec 19, 2018 at 12:07 AM Issac Trotts <issac.trotts@gmail.com> wrote:\n>\n> Travis showed one failure. I'm not sure if it's a flake.\n> https://travis-ci.org/ijt/git/builds/469843833. Rerunning it.\n>\n> On Tue, Dec 18, 2018 at 7:47 PM Issac Trotts <issac.trotts@gmail.com> wrote:\n> >\n> > On Tue, Dec 18, 2018 at 9:14 AM Issac Trotts <issac.trotts@gmail.com> wrote:\n> > >\n> > > Hi Peff, thanks for the feedback. I tried a variant of the command you\n> > > showed and it yielded a seg fault:\n> > > ```\n> > > [ issactrotts ~/git ] ./git diff-tree -s --pretty=tformat:'%S %H %s' HEAD\n> > > Segmentation fault: 11\n> > > ```\n> > > I'll see if I can track it down this evening.\n> >\n> > Okay, found it. My solution is to make %S not do anything for commands\n> > other than `log` since `log` is the only one that has --source defined\n> > as far as I can tell.\n> >\n> > I'm waiting for Travis to run and will post an updated patch if\n> > everything looks good there.\n> >\n> > > Issac\n> > >\n> > > On Mon, Dec 17, 2018 at 7:59 AM Jeff King <peff@peff.net> wrote:\n> > > >\n> > > > On Sun, Dec 16, 2018 at 10:25:14PM -0800, Issac Trotts wrote:\n> > > >\n> > > > > Make it possible to write for example\n> > > > >\n> > > > >         git log --format=\"%H,%S\"\n> > > > >\n> > > > > where the %S at the end is a new placeholder that prints out the ref\n> > > > > (tag/branch) for each commit.\n> > > >\n> > > > Seems like a reasonable thing to want.\n> > > >\n> > > > One curious thing about \"--source\" is that it requires cooperation from\n> > > > the actual traversal. So if you did:\n> > > >\n> > > >   git rev-list | git diff-tree --format=\"%H %S\"\n> > > >\n> > > > we don't have the %S information in the latter command. I think that's\n> > > > probably acceptable as long as it does something sane when we don't have\n> > > > that information (e.g., replace it with an empty string). It might also\n> > > > be worth calling out in the documentation.\n> > > >\n> > > > -Peff\n"}]}