Thread (1 message) 1 message, 1 author, 2016-06-15
  • (off-list ancestor, not in this archive)
  • Re: preserving mtime · Junio C Hamano <hidden> · 2016-06-15

Re: preserving mtime

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:52

Fabrizio Pollastri [off-list ref] writes:
is it possible to tell git to preserve the file modification time in a
checked out copy? It is useful when managing web files, where mtime is
tested by spiders for download decisions.
"git checkout branchA" after "git checkout branchB" would not
touch "file" if "file" are identical between two branches, so
the modification time is already preserved.

If the contents of "file" from the version you would want to
check out is different from the version you previously checked
out, and you still want to keep the old timestamp, then you are
trying to do something that a normal SCM user would actively not
want (e.g. doing so would screw up the build systems such as
"make").  Such a specialized need usually is addressed by the
build and install procedure of the application (in your case, a
website management).  Maybe your current build procedure may
blindly copy when installing:

	install: web.html
        	$(install) web.html $(dest)/var/www/web.html

but you may want to ignore certain classes of changes and avoid
re-installing to help crawlers.  You would do:

	install = ./myinstall.sh
	install: web.html
        	$(install) web.html $(dest)/var/www/web.html

and then ./myinstall.sh might look like:

	#!/bin/sh
	test -f "$2" &&
        compare-ignoring-minor-changes "$1" "$2" && exit 0
	install "$1" "$2"
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help