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

Re: [PATCH] --format=pretty: new modifiers cID, cIS, CIY

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 1, 2008, 23:04 UTC
Message-ID
<7vir188ej4.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<odb072ca.fsf@blue.sea.net>
Jari Aalto <jari.aalto@cante.net> writes:
Show 20 quoted lines
> +	case 'I':	/* date, ISO 8601 + fine grained details */
> +		switch (next) {
> +		case 'D':	/* up till date */
> +			strbuf_addstr(sb,
> +					show_date(date, tz,
> +						DATE_ISO8601_YYYYMMDD));
> +			return;
> +		case 'S':	/* up till date + sec */
> +			strbuf_addstr(sb,
> +					show_date(date, tz,
> +						DATE_ISO8601_YYYYMMDDHHMMSS));
> +
> +			return;
> +		default:	/* up till hour */
> +			strbuf_addstr(sb,
> +					show_date(date, tz,
> +						DATE_ISO8601_YYYYMMDDHHMM));
> +
> +		}
> +		return;

I think this "default" is not quite nice. If you want to support down-to-hour, you'd beter explicitly support 'H'. "default:" should error out, saying "Ah, oh, sorry, I do not support %cIX (yet)".

Otherwise, it casts the set of truncated ISO 8601 date format we supports in stone. People would depend on being able to say "%cIhour" and a new implementation cannot introduce %cIh modifier that means something.

But I do not like the idea of adding more short-hand format this way. I think we would very much prefer, instead of piling hacks on top of the originally supported "minimum set", to introduce a truly extensible syntax, like:

	%cT(flexible formatting specification for committer time)
or even
	%c(flexible formatting specification for committer info)

and that specification may say which field to format with what prettiness. For example:

	%c(name|initial) %c(time|local,HH:MM) %c(time|gmt,HH) <%c(email)>
might say:
	JCH 15:00 23 <gitster@pobox.com>
(23 is because US/Pacific is 8 hours behind right now).

Of course, %a(likewise for author time) can be defined the same way.

Previous: Jari AaltoNext: Tommy Thorn
Message 3 of 7 in “--format=pretty: new modifiers cID, cIS, CIY”
  1. --format=pretty: new modifiers cID, cIS, CIYJari Aalto, Feb 1, 2008
  2. --format=pretty: new modifiers cID, cIM, CISJari Aalto, Feb 1, 2008
  3. Junio C HamanoFeb 1, 2008
  4. Tommy ThornFeb 1, 2008
  5. Junio C HamanoFeb 1, 2008
  6. --format=pretty: new modifiers cID, cIS, CIYJari Aalto, Feb 2, 2008
  7. Jari AaltoFeb 2, 2008

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.