{"thread":{"id":"45023","subject":"How to use git show's \"%<(<N>[,trunc|ltrunc|mtrunc])\"?","startedAt":"2017-02-02T17:52:05Z","lastAt":"2017-02-04T11:49:50Z","messageCount":6,"participants":["Hilco Wijbenga","G. Sylvie Davies","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"310734","messageId":"CAE1pOi0-8JnnZbdm9vu1RwTU1mXr7dboLC3ito3LcvK9gkNi_A@mail.gmail.com","threadId":"45023","inReplyTo":null,"subject":"How to use git show's \"%<(<N>[,trunc|ltrunc|mtrunc])\"?","fromName":"Hilco Wijbenga","fromEmail":"hilco.wijbenga@gmail.com","sentAt":"2017-02-02T17:51:38Z","receivedAt":"2017-02-02T17:52:05Z","isPatch":false,"sender":{"key":"hilco.wijbenga@gmail.com","avatar":null},"body":"Hi all,\n\nI'm trying to get the committer date printed in a custom fashion.\nUsing \"%cI\" gets me close:\n\n$ git show --format=\"%cI | %an\" master | head -n 1\n2017-01-31T17:02:13-08:00 | Hilco Wijbenga\n\nI would like to get rid of the \"-08:00\" bit at the end of the\ntimestamp. According to the \"git show\" manual I should be able to use\n\"%<(<N>[,trunc|ltrunc|mtrunc])\" to drop that last part.\n\n$ git show --format=\"%<(19,trunc)cI | %an\" master | head -n 1\ncI | Hilco Wijbenga\n\nMmm, it seems to be recognized as a valid \"something\" but it's not\nworking as I had expected. :-) I tried several other versions of this\nbut no luck. Clearly, I'm misunderstanding the format description. How\ndo I get \"2017-01-31T17:02:13 | Hilco Wijbenga\" to be output?\n\nCheers,\nHilco\n"},{"id":"310785","messageId":"CAAj3zPz8wFc_5dRmM=-jMnqp6a7fGtc4XSyU5meF6mO5me47Dw@mail.gmail.com","threadId":"45023","inReplyTo":"CAE1pOi0-8JnnZbdm9vu1RwTU1mXr7dboLC3ito3LcvK9gkNi_A@mail.gmail.com","subject":"Re: How to use git show's \"%<(<N>[,trunc|ltrunc|mtrunc])\"?","fromName":"G. Sylvie Davies","fromEmail":"sylvie@bit-booster.com","sentAt":"2017-02-03T04:19:28Z","receivedAt":"2017-02-03T04:19:34Z","isPatch":false,"sender":{"key":"sylvie@bit-booster.com","avatar":"https://gravatar.com/avatar/eb5bda7d3fb1e3361252bbf100d1f355ffe9ff8d8b559a08e4c7bc17d6f949d5?d=mp&s=160"},"body":"On Thu, Feb 2, 2017 at 9:51 AM, Hilco Wijbenga <hilco.wijbenga@gmail.com> wrote:\n> Hi all,\n>\n> I'm trying to get the committer date printed in a custom fashion.\n> Using \"%cI\" gets me close:\n>\n> $ git show --format=\"%cI | %an\" master | head -n 1\n> 2017-01-31T17:02:13-08:00 | Hilco Wijbenga\n>\n> I would like to get rid of the \"-08:00\" bit at the end of the\n> timestamp. According to the \"git show\" manual I should be able to use\n> \"%<(<N>[,trunc|ltrunc|mtrunc])\" to drop that last part.\n>\n> $ git show --format=\"%<(19,trunc)cI | %an\" master | head -n 1\n> cI | Hilco Wijbenga\n>\n> Mmm, it seems to be recognized as a valid \"something\" but it's not\n> working as I had expected. :-) I tried several other versions of this\n> but no luck. Clearly, I'm misunderstanding the format description. How\n> do I get \"2017-01-31T17:02:13 | Hilco Wijbenga\" to be output?\n>\n\nWill this work for you?\n\n$ git show -s --pretty='%cd | %an' --date=format:%FT%R:%S\n2017-02-02T10:01:36 | G. Sylvie Davies\n\n\nI have no idea how portable this might be.  As \"git help log\" says:\n\n         --date=format:...  feeds the format ...  to your system\nstrftime. Use --date=format:%c to show the date in your system\nlocale’s preferred format. See the strftime manual for a complete list\nof format placeholders.\n\n\n\n- Sylvie\n"},{"id":"310786","messageId":"CAE1pOi1agWBHJHmnKkJ7A1EdhJoJausTX7fUeypLbDP6A2FuHQ@mail.gmail.com","threadId":"45023","inReplyTo":"CAAj3zPz8wFc_5dRmM=-jMnqp6a7fGtc4XSyU5meF6mO5me47Dw@mail.gmail.com","subject":"Re: How to use git show's \"%<(<N>[,trunc|ltrunc|mtrunc])\"?","fromName":"Hilco Wijbenga","fromEmail":"hilco.wijbenga@gmail.com","sentAt":"2017-02-03T04:32:14Z","receivedAt":"2017-02-03T04:32:41Z","isPatch":false,"sender":{"key":"hilco.wijbenga@gmail.com","avatar":null},"body":"On 2 February 2017 at 20:19, G. Sylvie Davies <sylvie@bit-booster.com> wrote:\n> On Thu, Feb 2, 2017 at 9:51 AM, Hilco Wijbenga <hilco.wijbenga@gmail.com> wrote:\n>> Hi all,\n>>\n>> I'm trying to get the committer date printed in a custom fashion.\n>> Using \"%cI\" gets me close:\n>>\n>> $ git show --format=\"%cI | %an\" master | head -n 1\n>> 2017-01-31T17:02:13-08:00 | Hilco Wijbenga\n>>\n>> I would like to get rid of the \"-08:00\" bit at the end of the\n>> timestamp. According to the \"git show\" manual I should be able to use\n>> \"%<(<N>[,trunc|ltrunc|mtrunc])\" to drop that last part.\n>>\n>> $ git show --format=\"%<(19,trunc)cI | %an\" master | head -n 1\n>> cI | Hilco Wijbenga\n>>\n>> Mmm, it seems to be recognized as a valid \"something\" but it's not\n>> working as I had expected. :-) I tried several other versions of this\n>> but no luck. Clearly, I'm misunderstanding the format description. How\n>> do I get \"2017-01-31T17:02:13 | Hilco Wijbenga\" to be output?\n>>\n>\n> Will this work for you?\n>\n> $ git show -s --pretty='%cd | %an' --date=format:%FT%R:%S\n> 2017-02-02T10:01:36 | G. Sylvie Davies\n\nAh, that does indeed do exactly what I want. Thank you.\n\n> I have no idea how portable this might be.  As \"git help log\" says:\n>\n>          --date=format:...  feeds the format ...  to your system\n> strftime. Use --date=format:%c to show the date in your system\n> locale’s preferred format. See the strftime manual for a complete list\n> of format placeholders.\n\nIt should be fine for my purposes.\n\nAny idea why \"%<(19,trunc)cl\" doesn't work? (Your solution solves my\noriginal problem perfectly but I'd like to understand how I'm\nmisreading the spec.)\n"},{"id":"310789","messageId":"CACsJy8DjqrEZ=VaZo6bn4i2r=Wr8k4ExYv48N-rDvfPO=hqpLA@mail.gmail.com","threadId":"45023","inReplyTo":"CAE1pOi0-8JnnZbdm9vu1RwTU1mXr7dboLC3ito3LcvK9gkNi_A@mail.gmail.com","subject":"Re: How to use git show's \"%<(<N>[,trunc|ltrunc|mtrunc])\"?","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-02-03T08:06:58Z","receivedAt":"2017-02-03T08:07:37Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Feb 3, 2017 at 12:51 AM, Hilco Wijbenga\n<hilco.wijbenga@gmail.com> wrote:\n> Hi all,\n>\n> I'm trying to get the committer date printed in a custom fashion.\n> Using \"%cI\" gets me close:\n>\n> $ git show --format=\"%cI | %an\" master | head -n 1\n> 2017-01-31T17:02:13-08:00 | Hilco Wijbenga\n>\n> I would like to get rid of the \"-08:00\" bit at the end of the\n> timestamp. According to the \"git show\" manual I should be able to use\n> \"%<(<N>[,trunc|ltrunc|mtrunc])\" to drop that last part.\n>\n> $ git show --format=\"%<(19,trunc)cI | %an\" master | head -n 1\n\nYou're almost there. Just insert another '%' between \"trunc)\" and \"cI\".\n\n> How do I get \"2017-01-31T17:02:13 | Hilco Wijbenga\" to be output?\n\nYou'll get an ellipsis at the end though.. (i.e. 02:13... | Hilco)\n-- \nDuy\n"},{"id":"310808","messageId":"CAE1pOi3ThTLSp_0ZJHto4p75Ds5NMGymHrD0ju9axCqA1+NkMA@mail.gmail.com","threadId":"45023","inReplyTo":"CACsJy8DjqrEZ=VaZo6bn4i2r=Wr8k4ExYv48N-rDvfPO=hqpLA@mail.gmail.com","subject":"Re: How to use git show's \"%<(<N>[,trunc|ltrunc|mtrunc])\"?","fromName":"Hilco Wijbenga","fromEmail":"hilco.wijbenga@gmail.com","sentAt":"2017-02-03T17:10:20Z","receivedAt":"2017-02-03T17:10:56Z","isPatch":false,"sender":{"key":"hilco.wijbenga@gmail.com","avatar":null},"body":"On 3 February 2017 at 00:06, Duy Nguyen <pclouds@gmail.com> wrote:\n> On Fri, Feb 3, 2017 at 12:51 AM, Hilco Wijbenga\n> <hilco.wijbenga@gmail.com> wrote:\n>> Hi all,\n>>\n>> I'm trying to get the committer date printed in a custom fashion.\n>> Using \"%cI\" gets me close:\n>>\n>> $ git show --format=\"%cI | %an\" master | head -n 1\n>> 2017-01-31T17:02:13-08:00 | Hilco Wijbenga\n>>\n>> I would like to get rid of the \"-08:00\" bit at the end of the\n>> timestamp. According to the \"git show\" manual I should be able to use\n>> \"%<(<N>[,trunc|ltrunc|mtrunc])\" to drop that last part.\n>>\n>> $ git show --format=\"%<(19,trunc)cI | %an\" master | head -n 1\n>\n> You're almost there. Just insert another '%' between \"trunc)\" and \"cI\".\n\nThank you so much! This has been bugging me. :-) Rereading \"git help\nshow\", I guess it's implied I should do this but it very much wasn't\nclear to me (obviously). I guess I'm too used to the \"%19.19s\" type of\napproach. Maybe there should be some examples?\n\n>> How do I get \"2017-01-31T17:02:13 | Hilco Wijbenga\" to be output?\n>\n> You'll get an ellipsis at the end though.. (i.e. 02:13... | Hilco)\n\nIndeed, that's not very nice. I suppose I can understand the reason\nfor it but it mostly defeats the purpose of \"trunc\", doesn't it?\nLuckily, Sylvie's solution does exactly what I want.\n"},{"id":"310847","messageId":"CACsJy8B3VULFCLyRf9Poeu7UnnZggGyV05-_4LiOO6pHjA++BA@mail.gmail.com","threadId":"45023","inReplyTo":"CAE1pOi3ThTLSp_0ZJHto4p75Ds5NMGymHrD0ju9axCqA1+NkMA@mail.gmail.com","subject":"Re: How to use git show's \"%<(<N>[,trunc|ltrunc|mtrunc])\"?","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-02-04T11:49:15Z","receivedAt":"2017-02-04T11:49:50Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Feb 4, 2017 at 12:10 AM, Hilco Wijbenga\n<hilco.wijbenga@gmail.com> wrote:\n>>> How do I get \"2017-01-31T17:02:13 | Hilco Wijbenga\" to be output?\n>>\n>> You'll get an ellipsis at the end though.. (i.e. 02:13... | Hilco)\n>\n> Indeed, that's not very nice. I suppose I can understand the reason\n> for it but it mostly defeats the purpose of \"trunc\", doesn't it?\n\nIt depends. When you truncate a commit subject line, you may want an\nindicator that you're not seeing the whole line. For fixed fields like\ndates when you expect every string to be truncated, then yes there's\nnot much point to show the ellipsis.\n-- \nDuy\n"}]}