Re: Git checkout preserve timestamp?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 2007 March 02 16:21, Karl Hasselström wrote:

> However, given that your file timestamps have been bumped (without
> file content changes), it's a performance bug in your make tool if

Actually, git is as good as it could reasonably get in this regard.

Let's say you did this:

 git checkout branch1
 git checkout branch2
 git checkout branch1

Git will only touch the timestamps of files that are different between the 
branches.  If the same file is in both branches, then that one remains 
untouched in your working tree (it's tricks like this that make git so 
blindingly fast).

The fact that you've changed back from branch2 to branch1 is the bone of 
contention - how is git meant to know that you haven't done a compilation 
while you were on branch2 and hence changed the files that untracked files 
depend on?  The /only/ sane thing it can do is, in both cases, update changed 
files to have the current time.

Perhaps an example would make it clearer:

 git checkout branch1
 # sourcefile.c changes, so git touches the timestamp
 # make would rebuild sourcefile.o
 git checkout branch2
 # sourcefile.c changes, so git touches the timestamp
 # make would rebuild sourcefile.o
 git checkout branch1
 # sourcefile.c changes, so git touches the timestamp
 # make would rebuild sourcefile.o

That's all exactly right, make knows in each case the the ".o" file is out of 
date because it has a timestamp earlier than sourcefile.c

Now take the suggestion that timestamps from the repository version should be 
restored and do the same thing:

 git checkout branch1
 # sourcefile.c changes, git sets the timestamp to $timestamp1
 # make would rebuild sourcefile.o (setting its timestamp to $now)
 git checkout branch2
 # sourcefile.c changes, so sets the timestamp to $timestamp2
 # make wouldn't rebuild sourcefile.o because $timestamp2 < $now
 git checkout branch1
 # sourcefile.c changes, so git sets the timestamp to $timestamp1
 # make wouldn't rebuild sourcefile.o because $timestamp1 < $now

All very wrong; in two out of the three builds, the wrong sourcefile.o ends up 
in the final object.

What git does now is absolutely the right thing.  It keeps unnecessary 
rebuilds to the safest minimum.



Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@xxxxxxxxx
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]