{"thread":{"id":"40508","subject":"[PATCH] pretty: add format specifiers for short and raw date formats","startedAt":"2015-10-07T16:28:25Z","lastAt":"2015-10-08T11:04:26Z","messageCount":3,"participants":["SZEDER Gábor","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"271260","messageId":"1444235305-8718-1-git-send-email-szeder@ira.uka.de","threadId":"40508","inReplyTo":null,"subject":"[PATCH] pretty: add format specifiers for short and raw date formats","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-10-07T16:28:25Z","receivedAt":"2015-10-07T16:28:25Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Other date formats already have their format specifiers and so should\nthese, so they will be available in pretty format aliases as well.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n Documentation/pretty-formats.txt | 4 ++++\n pretty.c                         | 6 ++++++\n 2 files changed, 10 insertions(+)\n\ndiff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt\nindex 671cebd95c..ce62c70659 100644\n--- a/Documentation/pretty-formats.txt\n+++ b/Documentation/pretty-formats.txt\n@@ -120,6 +120,8 @@ The placeholders are:\n - '%at': author date, UNIX timestamp\n - '%ai': author date, ISO 8601-like format\n - '%aI': author date, strict ISO 8601 format\n+- '%as': author date, short format\n+- '%aR': author date, raw format\n - '%cn': committer name\n - '%cN': committer name (respecting .mailmap, see\n   linkgit:git-shortlog[1] or linkgit:git-blame[1])\n@@ -132,6 +134,8 @@ The placeholders are:\n - '%ct': committer date, UNIX timestamp\n - '%ci': committer date, ISO 8601-like format\n - '%cI': committer date, strict ISO 8601 format\n+- '%cs': committer date, short format\n+- '%cR': committer date, raw format\n - '%d': ref names, like the --decorate option of linkgit:git-log[1]\n - '%D': ref names without the \" (\", \")\" wrapping.\n - '%e': encoding\ndiff --git a/pretty.c b/pretty.c\nindex 151c2ae312..e3ea2c03b0 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -723,6 +723,12 @@ static size_t format_person_part(struct strbuf *sb, char part,\n \tcase 'I':\t/* date, ISO 8601 strict */\n \t\tstrbuf_addstr(sb, show_ident_date(&s, DATE_MODE(ISO8601_STRICT)));\n \t\treturn placeholder_len;\n+\tcase 's':\t/* date, short */\n+\t\tstrbuf_addstr(sb, show_ident_date(&s, DATE_MODE(SHORT)));\n+\t\treturn placeholder_len;\n+\tcase 'R':\t/* date, raw */\n+\t\tstrbuf_addstr(sb, show_ident_date(&s, DATE_MODE(RAW)));\n+\t\treturn placeholder_len;\n \t}\n \n skip:\n-- \n2.6.1.134.ge857153\n"},{"id":"271273","messageId":"xmqqmvvutone.fsf@gitster.mtv.corp.google.com","threadId":"40508","inReplyTo":"1444235305-8718-1-git-send-email-szeder@ira.uka.de","subject":"Re: [PATCH] pretty: add format specifiers for short and raw date formats","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-10-07T20:22:13Z","receivedAt":"2015-10-07T20:22:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"SZEDER Gábor <szeder@ira.uka.de> writes:\n\n> @@ -120,6 +120,8 @@ The placeholders are:\n>  - '%at': author date, UNIX timestamp\n>  - '%ai': author date, ISO 8601-like format\n>  - '%aI': author date, strict ISO 8601 format\n> +- '%as': author date, short format\n> +- '%aR': author date, raw format\n\nHmmm, are these two a good things the only ones that are missing?\n\nIt makes me wonder if it's time for us to move to a more extensible\nformat, e.g. \"%aT(...)\", in which 'T' stands for 'timestamp' and the\npart in the parentheses can be any format string that is understood\nby \"log --date=<format>\" [*1*].  Once we have something like that,\nwe can keep the existing ones for historical convenience, stop\nadding new ones [*2*] and do not have to worry about these two\nmechanisms going out of sync.\n\nAlso, \"%at\" is almost there as a replacement for \"%aR\"; what we are\nmissing really is \"%aZ\" for zone offset.  If we had \"%aZ\", we do not\nneed \"%aR\", as that is \"%at %aZ\".\n\n\n[Footnote]\n\n*1* Yes, and in longer term, we should really aim to unify the\n    for-each-ref format and \"--pretty=format:\" format.  \"%aT(...)\"\n    is probably a step in a wrong direction, and it should probably\n    be more like \"%(authordate:...)\".\n\n*2* Because we have \"%ad\", we _can_ stop adding new ones already.\n"},{"id":"271314","messageId":"20151008130426.Horde.ovF3CHaJ-fo48aLDf23t-Q1@webmail.informatik.kit.edu","threadId":"40508","inReplyTo":"xmqqmvvutone.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] pretty: add format specifiers for short and raw date formats","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2015-10-08T11:04:26Z","receivedAt":"2015-10-08T11:04:26Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"\nQuoting Junio C Hamano <gitster@pobox.com>:\n\n> SZEDER Gábor <szeder@ira.uka.de> writes:\n>\n>> @@ -120,6 +120,8 @@ The placeholders are:\n>>  - '%at': author date, UNIX timestamp\n>>  - '%ai': author date, ISO 8601-like format\n>>  - '%aI': author date, strict ISO 8601 format\n>> +- '%as': author date, short format\n>> +- '%aR': author date, raw format\n>\n> Hmmm, are these two a good things the only ones that are missing?\n\nSort of.  There is 'local', but after add00ba2de (date: make \"local\"\northogonal to date format, 2015-09-03) hit master that's not a\nformat anymore.\n\n> It makes me wonder if it's time for us to move to a more extensible\n> format, e.g. \"%aT(...)\", in which 'T' stands for 'timestamp' and the\n> part in the parentheses can be any format string that is understood\n> by \"log --date=<format>\" [*1*].  Once we have something like that,\n> we can keep the existing ones for historical convenience, stop\n> adding new ones [*2*] and do not have to worry about these two\n> mechanisms going out of sync.\n\n> *1* Yes, and in longer term, we should really aim to unify the\n>     for-each-ref format and \"--pretty=format:\" format.  \"%aT(...)\"\n>     is probably a step in a wrong direction, and it should probably\n>     be more like \"%(authordate:...)\".\n\nThat would be great, especially that in [*1*].  Real words are so\nmuch better than one or two letter codes.\nOf course that would also be a lot more invasive change.\n\n> *2* Because we have \"%ad\", we _can_ stop adding new ones already.\n\nWith this patch in my tree I have this pretty alias\n\n   pretty.commitref=tformat:%h (%s, %as)\n\nin my config, and a simple '--pretty=commitref' option works on its\nown to produce the format that I used above.  With '%ad' that\nwouldn't work, because I would need the additional '--date=short'\noption, too, which means I have to remember it and have to type more\nevery time.\n\nGábor\n"}]}