git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: git@vger.kernel.org
Subject: Re: Setting file timestamps to commit time (git-checkout)
Date: Mon, 9 Dec 2013 12:48:16 -0800	[thread overview]
Message-ID: <20131209204815.GV29959@google.com> (raw)
In-Reply-To: <20131209112528.GA5309@linux.vnet.ibm.com>

Hi,

Dominik Vogt wrote:

>                                                            Now,
> when I switch to one of the other branches, said file is not
> identical anymore and stamped with the _current_ time during
> checkout.  Although branch b and c have not changed at all, they
> will now be rebuilt completely because the timestamp on that files
> has changed.  I.e. a chance on one branch forces a rebuild on n
> other branches, which can take many hours.
>
> I think this situation could be improved with an option to
> git-checkout with the following logic:
>
> $ git checkout <new branch>
>   FOR EACH <file> in working directory of <new branch>
>     IF <file> is identical to the version in the <old branch>
>       THEN leave the file untouched
>     ELSE IF <commit timestamp> of the HEAD of the <new branch>
>             is in the future
>       THEN checkout the new version of <file> and stamp it with
>            the current time
>     ELSE (commit timestamp is current or in the past)
>       THEN checkout the new version of <file> and stamp it with
>            the commit timestamp of the current HEAD of <new branch>

Wouldn't that break "make"?  When you switch to an old branch, changed
files would then a timestamp *before* the corresponding build targets,
causing the stale (wrong function signatures, etc) build results from
the newer branch to be reused and breaking the build.

I suspect the simplest way to accomplish what you're looking for would
be to keep separate worktrees for each branch you regularly build.
It's possible to do that using entirely independent clones, clones
sharing some objects (using "git clone --shared" from some master
copy), or even multiple worktrees for the same clone (using the
git-new-workdir script from contrib/workdir/).

See [1] and [2] for more hints.

[...]
> (Please do not cc me on replies, I'm subscribed to the list.)

The convention on this list is to always reply-to-all, but I'm happy
to make an exception. :)

Hope that helps,
Jonathan

[1] https://git.wiki.kernel.org/index.php/Git_FAQ#Why_isn.27t_Git_preserving_modification_time_on_files.3F
[2] https://git.wiki.kernel.org/index.php/ExampleScripts#Setting_the_timestamps_of_the_files_to_the_commit_timestamp_of_the_commit_which_last_touched_them

  parent reply	other threads:[~2013-12-09 20:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09 11:25 Setting file timestamps to commit time (git-checkout) Dominik Vogt
2013-12-09 20:35 ` Junio C Hamano
2013-12-10  8:35   ` Dominik Vogt
2013-12-10 19:02     ` Andreas Schwab
2013-12-11  7:37       ` Dominik Vogt
2013-12-11  1:39     ` Constantine A. Murenin
2013-12-09 20:48 ` Jonathan Nieder [this message]
2013-12-10  8:46   ` Dominik Vogt
2013-12-10 10:34     ` Duy Nguyen
2013-12-11  1:08       ` Jonathan Nieder
2013-12-11  1:01     ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131209204815.GV29959@google.com \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).