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

Re: [PATCH] guilt: Make sure the commit time is increasing

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 6, 2010, 08:03 UTC
Message-ID
<20100706080322.GA2856@burratino>
In-Reply-To
<20100705192201.GI25518@thunk.org>
tytso@mit.edu wrote:
> On Mon, Jul 05, 2010 at 02:52:38PM -0400, jeffpc@josefsipek.net wrote:
>> if I commit, and immediately after push 10 patches, wouldn't the HEAD end up
>> with a commit that's ~10 minutes in the future?

I don’t think git has ever required commit dates to be _strictly_ monotonic.

At one point rev-list did require monotonic --- i.e., the committer date of each commit had to be equal to or later than that of each of its parents) with no clock skew but that was considered a bug and fixed by v1.5.5-rc1~16 (Make revision limiting more robust against occasional bad commit dates, 2008-03-17)

Show 16 quoted lines
> diff --git a/guilt b/guilt
> index b6e2a6c..edcfb34 100755
> --- a/guilt
> +++ b/guilt
> @@ -535,6 +535,17 @@ commit()
>                          export GIT_AUTHOR_EMAIL="`echo $author_str | sed -e 's/[^<]*//'`"
>  		fi
>  
> +		ct=$(git log -1 --pretty=%ct)
> +		if [ $ct -gt $(stat -c %Y "$p") ]; then
> +		    echo "Adjusting mod time of" $(basename "$p")
> +		    ct=$(expr $ct + 60)
> +		    if [ $ct -gt $(date +%s) ]; then
> +			touch "$p"
> +		    else
> +			touch -d @$(expr $ct + 60) "$p"
So I would suggest
 echo "Adjusting mod time of $(basename "$p")"
 touch -d "$ct" "$p"

If the parent commit time happens to be in the future, well, at least we’re not making it worse.

By the way, I think your idea to have commit warn about nonmonotonic commit dates is a good one. We should also decide on a rule, hopefully one the kernel repo obeys (30 days max skew? *crosses fingers*) and make git fsck warn loudly about violations.

Previous: tytso@mit.eduNext: Theodore Tso
Message 8 of 19 in “guilt: Make sure the commit time is increasing”
  1. guilt: Make sure the commit time is increasingTheodore Ts'o, Jul 5, 2010
  2. tytso@mit.eduJul 5, 2010
  3. jeffpc@josefsipek.netJul 5, 2010
  4. jeffpc@josefsipek.netJul 5, 2010
  5. Theodore TsoJul 5, 2010
  6. jeffpc@josefsipek.netJul 5, 2010
  7. tytso@mit.eduJul 5, 2010
  8. Jonathan NiederJul 6, 2010
  9. Theodore TsoJul 6, 2010
  10. Jonathan NiederJul 6, 2010
  11. tytso@mit.eduJul 6, 2010
  12. Jonathan NiederJul 6, 2010
  13. Erik Faye-LundJul 6, 2010
  14. Jeff KingJul 6, 2010
  15. Erik Faye-LundJul 6, 2010
  16. tytso@mit.eduJul 6, 2010
  17. jeffpc@josefsipek.netJul 6, 2010
  18. tytso@mit.eduJul 6, 2010
  19. Josef 'Jeff' SipekJul 14, 2010

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.