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

Re: Reverting/cheout files with old modification date

From
FCFabrizio Chiarello <fabrizio.chiarello@ieee.org>
Date
Jun 10, 2011, 07:17 UTC
Message-ID
<20110610071707.GA4715@hydrogen.black.hole>
In-Reply-To
<loom.20110609T090306-164@post.gmane.org>
On Thu, Jun 09, 2011 at 07:09:47AM +0000, Peter Pientka wrote:
Show 5 quoted lines
> Hi,
> Is any way to revert/checkout some files from reposotory with old modification
> date(file parameter). Now, while I revert/checkout some file, modification date
> of file is set to current date and time.
> 

I use this hook. On checkout it sets the mtime of all the files to the date of the last commit touching them.

===== .git/hooks/post-checkout
#!/bin/sh
for f in `git ls-tree --name-only -r HEAD`; do
    mtime=`git log -n1 --date=iso --pretty=%ai -- $f`
    touch -m -d "$mtime" $f
done
=====
-- 
Fabrizio Chiarello <fabrizio.chiarello@ieee.org>

You ask: what is the meaning or purpose of life? I can only answer with
another question: do you think we are wise enough to read God's mind?
  -- Freeman Dyson
Previous: Peter Pientka
Message 2 of 2 in “Reverting/cheout files with old modification date”
  1. Peter PientkaJun 9, 2011
  2. Fabrizio ChiarelloJun 10, 2011

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.