git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] pretty: add format specifiers for short and raw date formats
@ 2015-10-07 16:28 SZEDER Gábor
  2015-10-07 20:22 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: SZEDER Gábor @ 2015-10-07 16:28 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git, SZEDER Gábor

Other date formats already have their format specifiers and so should
these, so they will be available in pretty format aliases as well.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 Documentation/pretty-formats.txt | 4 ++++
 pretty.c                         | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index 671cebd95c..ce62c70659 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -120,6 +120,8 @@ The placeholders are:
 - '%at': author date, UNIX timestamp
 - '%ai': author date, ISO 8601-like format
 - '%aI': author date, strict ISO 8601 format
+- '%as': author date, short format
+- '%aR': author date, raw format
 - '%cn': committer name
 - '%cN': committer name (respecting .mailmap, see
   linkgit:git-shortlog[1] or linkgit:git-blame[1])
@@ -132,6 +134,8 @@ The placeholders are:
 - '%ct': committer date, UNIX timestamp
 - '%ci': committer date, ISO 8601-like format
 - '%cI': committer date, strict ISO 8601 format
+- '%cs': committer date, short format
+- '%cR': committer date, raw format
 - '%d': ref names, like the --decorate option of linkgit:git-log[1]
 - '%D': ref names without the " (", ")" wrapping.
 - '%e': encoding
diff --git a/pretty.c b/pretty.c
index 151c2ae312..e3ea2c03b0 100644
--- a/pretty.c
+++ b/pretty.c
@@ -723,6 +723,12 @@ static size_t format_person_part(struct strbuf *sb, char part,
 	case 'I':	/* date, ISO 8601 strict */
 		strbuf_addstr(sb, show_ident_date(&s, DATE_MODE(ISO8601_STRICT)));
 		return placeholder_len;
+	case 's':	/* date, short */
+		strbuf_addstr(sb, show_ident_date(&s, DATE_MODE(SHORT)));
+		return placeholder_len;
+	case 'R':	/* date, raw */
+		strbuf_addstr(sb, show_ident_date(&s, DATE_MODE(RAW)));
+		return placeholder_len;
 	}
 
 skip:
-- 
2.6.1.134.ge857153

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pretty: add format specifiers for short and raw date formats
  2015-10-07 16:28 [PATCH] pretty: add format specifiers for short and raw date formats SZEDER Gábor
@ 2015-10-07 20:22 ` Junio C Hamano
  2015-10-08 11:04   ` SZEDER Gábor
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2015-10-07 20:22 UTC (permalink / raw
  To: SZEDER Gábor; +Cc: git

SZEDER Gábor <szeder@ira.uka.de> writes:

> @@ -120,6 +120,8 @@ The placeholders are:
>  - '%at': author date, UNIX timestamp
>  - '%ai': author date, ISO 8601-like format
>  - '%aI': author date, strict ISO 8601 format
> +- '%as': author date, short format
> +- '%aR': author date, raw format

Hmmm, are these two a good things the only ones that are missing?

It makes me wonder if it's time for us to move to a more extensible
format, e.g. "%aT(...)", in which 'T' stands for 'timestamp' and the
part in the parentheses can be any format string that is understood
by "log --date=<format>" [*1*].  Once we have something like that,
we can keep the existing ones for historical convenience, stop
adding new ones [*2*] and do not have to worry about these two
mechanisms going out of sync.

Also, "%at" is almost there as a replacement for "%aR"; what we are
missing really is "%aZ" for zone offset.  If we had "%aZ", we do not
need "%aR", as that is "%at %aZ".


[Footnote]

*1* Yes, and in longer term, we should really aim to unify the
    for-each-ref format and "--pretty=format:" format.  "%aT(...)"
    is probably a step in a wrong direction, and it should probably
    be more like "%(authordate:...)".

*2* Because we have "%ad", we _can_ stop adding new ones already.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pretty: add format specifiers for short and raw date formats
  2015-10-07 20:22 ` Junio C Hamano
@ 2015-10-08 11:04   ` SZEDER Gábor
  0 siblings, 0 replies; 3+ messages in thread
From: SZEDER Gábor @ 2015-10-08 11:04 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git


Quoting Junio C Hamano <gitster@pobox.com>:

> SZEDER Gábor <szeder@ira.uka.de> writes:
>
>> @@ -120,6 +120,8 @@ The placeholders are:
>>  - '%at': author date, UNIX timestamp
>>  - '%ai': author date, ISO 8601-like format
>>  - '%aI': author date, strict ISO 8601 format
>> +- '%as': author date, short format
>> +- '%aR': author date, raw format
>
> Hmmm, are these two a good things the only ones that are missing?

Sort of.  There is 'local', but after add00ba2de (date: make "local"
orthogonal to date format, 2015-09-03) hit master that's not a
format anymore.

> It makes me wonder if it's time for us to move to a more extensible
> format, e.g. "%aT(...)", in which 'T' stands for 'timestamp' and the
> part in the parentheses can be any format string that is understood
> by "log --date=<format>" [*1*].  Once we have something like that,
> we can keep the existing ones for historical convenience, stop
> adding new ones [*2*] and do not have to worry about these two
> mechanisms going out of sync.

> *1* Yes, and in longer term, we should really aim to unify the
>     for-each-ref format and "--pretty=format:" format.  "%aT(...)"
>     is probably a step in a wrong direction, and it should probably
>     be more like "%(authordate:...)".

That would be great, especially that in [*1*].  Real words are so
much better than one or two letter codes.
Of course that would also be a lot more invasive change.

> *2* Because we have "%ad", we _can_ stop adding new ones already.

With this patch in my tree I have this pretty alias

   pretty.commitref=tformat:%h (%s, %as)

in my config, and a simple '--pretty=commitref' option works on its
own to produce the format that I used above.  With '%ad' that
wouldn't work, because I would need the additional '--date=short'
option, too, which means I have to remember it and have to type more
every time.

Gábor

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-08 11:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-07 16:28 [PATCH] pretty: add format specifiers for short and raw date formats SZEDER Gábor
2015-10-07 20:22 ` Junio C Hamano
2015-10-08 11:04   ` SZEDER Gábor

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).