{"thread":{"id":"41046","subject":"`format:%>` padding and `git log --graph`","startedAt":"2015-12-20T16:41:44Z","lastAt":"2015-12-22T16:08:50Z","messageCount":3,"participants":["Elliott Cable","Duy Nguyen","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"274781","messageId":"CAPZ477ObN53VffNVvHVuqT0MQ2Csu70i0+himmmjvPj1wfXjUQ@mail.gmail.com","threadId":"41046","inReplyTo":null,"subject":"`format:%>` padding and `git log --graph`","fromName":"Elliott Cable","fromEmail":"me@ell.io","sentAt":"2015-12-20T16:41:44Z","receivedAt":"2015-12-20T16:41:44Z","isPatch":false,"sender":{"key":"me@ell.io","avatar":"https://gravatar.com/avatar/0d35bb7d7c29b6bbcaafdf13ec70745573d31cb222130cc754a064e707c08d63?d=mp&s=160"},"body":"I'm not sure what version the `%>` / `<|` / etc padding showed up in,\nbut they're truly excellent for building beautiful one-line `git log`\noutput.\n\nThis may be a long-shot, but, unfortunately, these new formats sort of\nfall flat in the presence of `git log --graph`: The ‘pad until column’\nfeature, which when reading the manpage, I desperately hoped\n*specifically exists* to replace the normal ‘pad with spaces’ in\nsituations where `--graph` adds an un-known number of characters to the\nstart of the line ... unfortunately doesn't seem to work that way.\n\nFor instance, here's some truncated output from a basic `--graph`:\n\n    $ git log --graph --abbrev=8 --pretty=\"tformat:%h %s\"\n    ...\n    * | a4402023 + basic boilerplate for Liability / LiabilityFamily\n    * |   32ed6de8 Merge branch 'queueless' into queueless+\n    |\\ \\\n    | * \\   1e53ea10 (merge misc) Bring in some `bats` fixes, and re-sty\n    | |\\ \\\n    | | |/\n    | | * c8c270ff (!! new doc) Add rationale for basically *all* of the\n\nHere's what `%>|(16)%h` gives me:\n\n    $ git log --graph --abbrev=8 --pretty=\"tformat:%>|(16)%h %s\"\n    ...\n    * |         a4402023 + basic boilerplate for Liability / LiabilityFa\n    * |           32ed6de8 Merge branch 'queueless' into queueless+\n    |\\ \\\n    | * \\           1e53ea10 (merge misc) Bring in some `bats` fixes, an\n    | |\\ \\\n    | | |/\n    | | *         c8c270ff (!! new doc) Add rationale for basically *all\n\nHere's something like what I'd *like* to have seen:\n\n    $ git log --graph --abbrev=8 --pretty=\"tformat:%>|(16)%h %s\"\n    ...\n    * |     a4402023 + basic boilerplate for Liability / LiabilityFamily\n    * |     32ed6de8 Merge branch 'queueless' into queueless+\n    |\\ \\\n    | * \\   1e53ea10 (merge misc) Bring in some `bats` fixes, and re-sty\n    | * \\   1e53ea10 (merge misc) Bring in some `bats` fixes, and re-sty\n    | |\\ \\\n    | | |/\n    | | *   c8c270ff (!! new doc) Add rationale for basically *all* of t\n\nSo: Is this nigh-unimplementable? I once [dove into the git-log\nsource][patch], and I recall the `--graph` code being terrifying; so if\nthis is difficult to support, I can see why it would be left out.\n\nIf I'm off, though, and this is just an oversight, it'd be really neat\nto see somebody implement it! (=\n\n\n⁓ ELLIOTTCABLE — fly safe.\n  http://ell.io/tt\n\n   [patch]: <http://article.gmane.org/gmane.comp.version-control.git/226387>\n"},{"id":"274850","messageId":"20151222113309.GA8804@lanh","threadId":"41046","inReplyTo":"CAPZ477ObN53VffNVvHVuqT0MQ2Csu70i0+himmmjvPj1wfXjUQ@mail.gmail.com","subject":"Re: `format:%>` padding and `git log --graph`","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2015-12-22T11:33:09Z","receivedAt":"2015-12-22T11:33:09Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sun, Dec 20, 2015 at 10:41:44AM -0600, Elliott Cable wrote:\n> I'm not sure what version the `%>` / `<|` / etc padding showed up in,\n> but they're truly excellent for building beautiful one-line `git log`\n> output.\n\nSomebody found my code useful!! :-D\n\n> This may be a long-shot, but, unfortunately, these new formats sort of\n> fall flat in the presence of `git log --graph`: The ‘pad until column’\n> feature, which when reading the manpage, I desperately hoped\n> *specifically exists* to replace the normal ‘pad with spaces’ in\n> situations where `--graph` adds an un-known number of characters to the\n> start of the line ... unfortunately doesn't seem to work that way.\n> \n> For instance, here's some truncated output from a basic `--graph`:\n> \n>     $ git log --graph --abbrev=8 --pretty=\"tformat:%h %s\"\n>     ...\n>     * | a4402023 + basic boilerplate for Liability / LiabilityFamily\n>     * |   32ed6de8 Merge branch 'queueless' into queueless+\n>     |\\ \\\n>     | * \\   1e53ea10 (merge misc) Bring in some `bats` fixes, and re-sty\n>     | |\\ \\\n>     | | |/\n>     | | * c8c270ff (!! new doc) Add rationale for basically *all* of the\n> \n> Here's what `%>|(16)%h` gives me:\n> \n>     $ git log --graph --abbrev=8 --pretty=\"tformat:%>|(16)%h %s\"\n>     ...\n>     * |         a4402023 + basic boilerplate for Liability / LiabilityFa\n>     * |           32ed6de8 Merge branch 'queueless' into queueless+\n>     |\\ \\\n>     | * \\           1e53ea10 (merge misc) Bring in some `bats` fixes, an\n>     | |\\ \\\n>     | | |/\n>     | | *         c8c270ff (!! new doc) Add rationale for basically *all\n> \n> Here's something like what I'd *like* to have seen:\n> \n>     $ git log --graph --abbrev=8 --pretty=\"tformat:%>|(16)%h %s\"\n>     ...\n>     * |     a4402023 + basic boilerplate for Liability / LiabilityFamily\n>     * |     32ed6de8 Merge branch 'queueless' into queueless+\n>     |\\ \\\n>     | * \\   1e53ea10 (merge misc) Bring in some `bats` fixes, and re-sty\n>     | * \\   1e53ea10 (merge misc) Bring in some `bats` fixes, and re-sty\n>     | |\\ \\\n>     | | |/\n>     | | *   c8c270ff (!! new doc) Add rationale for basically *all* of t\n> \n> So: Is this nigh-unimplementable? I once [dove into the git-log\n> source][patch], and I recall the `--graph` code being terrifying; so if\n> this is difficult to support, I can see why it would be left out.\n\nYeah graph drawing code does not fit well with other format\nspecifiers. But it does not look that hard to achieve what you want,\nassuming that you specify the fixed width of the first column because\ncalculating it dynamically can be very expensive and the first column\ncould fill the entire screen (in merge forests like git.git).\n\nA starting point is something like this, which gives me something like\nyour output. If you can add a new option to specify the graph width,\nthen it may be an acceptable solution, I think.\n\ndiff --git a/graph.c b/graph.c\nindex c25a09a..8815984 100644\n--- a/graph.c\n+++ b/graph.c\n@@ -430,6 +430,8 @@ static void graph_update_width(struct git_graph *graph,\n \t * Each column takes up 2 spaces\n \t */\n \tgraph->width = max_cols * 2;\n+\tif (graph->width < 20)\n+\t\tgraph->width = 20;\n }\n \n static void graph_update_columns(struct git_graph *graph)\n\n> If I'm off, though, and this is just an oversight, it'd be really neat\n> to see somebody implement it! (=\n\nNope. Your itch. Your patch ;)\n--\nDuy\n"},{"id":"274890","messageId":"xmqqlh8mea99.fsf@gitster.mtv.corp.google.com","threadId":"41046","inReplyTo":"20151222113309.GA8804@lanh","subject":"Re: `format:%>` padding and `git log --graph`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-12-22T16:08:50Z","receivedAt":"2015-12-22T16:08:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Sun, Dec 20, 2015 at 10:41:44AM -0600, Elliott Cable wrote:\n>> I'm not sure what version the `%>` / `<|` / etc padding showed up in,\n>> but they're truly excellent for building beautiful one-line `git log`\n>> output.\n>\n> Somebody found my code useful!! :-D\n\nIs this related to\n\n    http://thread.gmane.org/gmane.comp.version-control.git/277710/focus=278326\n\nin any way?  My gut feeling is that, while the original patch itself\nbreaks existing uses and is not acceptable as-is, its idea is good,\nand we are OK with a change like that if it added a new/different\nkind of %>|(N) that makes the new behaviour available to those who\nwant to use it, without negatively affecting existing uses.\n"}]}