git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add a --dateformat= option to git-for-each-ref

From
Jeff King <peff@peff.net>
Date
Sep 26, 2007, 12:58 UTC
Message-ID
<20070926125811.GC13739@coredump.intra.peff.net>
In-Reply-To
<200709261009.18777.andyparkins@gmail.com>
On Wed, Sep 26, 2007 at 10:09:18AM +0100, Andy Parkins wrote:
Show 6 quoted lines
> For example (I'm in BST, +0100 at present):
> 
>  $ git-for-each-ref --dateformat=normal --format='%(taggerdate)' refs/tags/v1.5.2
>  Sun May 20 00:30:42 2007 -0700
>  $ git-for-each-ref --dateformat=relative --format='%(taggerdate)' refs/tags/v1.5.2
>  4 months ago

What if you want a format that contains two dates in different formats? Something like:

 $ git-for-each-ref --format='%(committerdate:relative) %(authordate:normal)'

would be more flexible. Although perhaps that is a bit too unlikely to be concerned with implementing, giving options to substitutions seems like a sane way to implement these sorts of things (e.g., "%(objectsize:human)", "%(parent:1)", etc).

Show 15 quoted lines
> +		if (!prefixcmp(arg, "--dateformat=")) {
> +			arg += 13;
> +			if (!prefixcmp(arg,"relative")) {
> +				date_mode = DATE_RELATIVE;
> +			} else if (!prefixcmp(arg,"short")) {
> +				date_mode = DATE_SHORT;
> +			} else if (!prefixcmp(arg,"local")) {
> +				date_mode = DATE_LOCAL;
> +			} else if (!prefixcmp(arg,"iso8601")) {
> +				date_mode = DATE_ISO8601;
> +			} else if (!prefixcmp(arg,"rfc2822")) {
> +				date_mode = DATE_RFC2822;
> +			}
> +			continue;
> +		}

Surely this same code exists elsewhere, and could be easily factored out into a parse_date_type function.

-Peff
Previous: Andy ParkinsNext: Andy Parkins
Message 2 of 15 in “Add a --dateformat= option to git-for-each-ref”
  1. Add a --dateformat= option to git-for-each-refAndy Parkins, Sep 26, 2007
  2. Jeff KingSep 26, 2007
  3. Andy ParkinsSep 28, 2007
  4. 1/4 Add parse_date_format() convenience function for converting a format string to an enum date_modeAndy Parkins, Sep 28, 2007
  5. 2/4 Use parse_date_format() in revisions.c to parse the --date parameterAndy Parkins, Sep 28, 2007
  6. Johannes SchindelinSep 28, 2007
  7. Andy ParkinsSep 28, 2007
  8. Junio C HamanoSep 28, 2007
  9. 1/3 Use parse_date_format() convenience function for converting a format string to an enum date_mode in revisions.cAndy Parkins, Sep 29, 2007
  10. 2/3 Make for-each-ref allow atom names like "<name>:<something>"Andy Parkins, Sep 29, 2007
  11. 3/3 Make for-each-ref's grab_date() support per-atom formattingAndy Parkins, Sep 29, 2007
  12. 3/4 Make for-each-ref allow atom names like "<name>:<something>"Andy Parkins, Sep 28, 2007
  13. 4/4 Make for-each-ref's grab_date() support per-atom formattingAndy Parkins, Sep 28, 2007
  14. Junio C HamanoSep 29, 2007
  15. Jeff KingSep 28, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.