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

Re: [BUG] minor: wrong handling of GIT_AUTHOR_DATE

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 17, 2008, 05:27 UTC
Message-ID
<7vljyw9pok.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<alpine.LFD.1.10.0808162054050.3324@nehalem.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 6 quoted lines
> [ Those four deleted lines I removed just because the cases had already 
>   been handled, eg the ">1900" case was already handled when we checked 
>   for a four-digit year, and the >70 case was handled when we checked for 
>   exactly two digits ]
>
> Hmm?
Show 11 quoted lines
> @@ -488,10 +504,6 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt
>  
>  	if (num > 0 && num < 32) {
>  		tm->tm_mday = num;
> -	} else if (num > 1900) {
> -		tm->tm_year = num - 1900;
> -	} else if (num > 70) {
> -		tm->tm_year = num;
>  	} else if (num > 0 && num < 13) {
>  		tm->tm_mon = num-1;
>  	}

The comment above this part says we always favor mday over mon, but I wonder why this sequence is not like:

	if (tm->tm_mday is not set && num > 0 && num < 32)
		tm->tm_mday = num;
	else if (tm->tm_mon is not set && num > 0 && num < 13)
		tm->tm_mon = num - 1;

Is this because we do not initialize tm fields to "unknown" in the beginning? I admit I haven't bothered to look at this part of the code for a looong time.

Previous: Linus TorvaldsNext: Linus Torvalds
Message 8 of 10 in “[BUG] minor: wrong handling of GIT_AUTHOR_DATE”
  1. Hermann GaustererAug 16, 2008
  2. Linus TorvaldsAug 16, 2008
  3. Linus TorvaldsAug 16, 2008
  4. Junio C HamanoAug 17, 2008
  5. Junio C HamanoAug 17, 2008
  6. Linus TorvaldsAug 17, 2008
  7. Linus TorvaldsAug 17, 2008
  8. Junio C HamanoAug 17, 2008
  9. Linus TorvaldsAug 17, 2008
  10. Linus TorvaldsAug 17, 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.