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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 26, 2007 at 10:09:18AM +0100, Andy Parkins wrote:

> 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).

> +		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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux