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

Re: Setting file timestamps to commit time (git-checkout)

From
DVDominik Vogt <vogt@linux.vnet.ibm.com>
Date
Dec 10, 2013, 08:46 UTC
Message-ID
<20131210084622.GC4087@linux.vnet.ibm.com>
In-Reply-To
<20131209204815.GV29959@google.com>
On Mon, Dec 09, 2013 at 12:48:16PM -0800, Jonathan Nieder wrote:
Show 27 quoted lines
> Dominik Vogt wrote:
> > 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.

Yes, if you share a common build directory, this logic would utterly break the build system. The point with gcc is, that you do not build it in the source tree but in a separate build directory, and it's easy to have separate build directories for your branches.

Show 6 quoted lines
> 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/).

I've tried the first two ways for separate workdirs in the past but did not like them. How does git-new-workdir cope with rebasing (e.g. you have the same branch checked out in two working trees and "rebase -i" it in one of them)? Is it really a working option?

> > (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. :)

It's just a hint; anyway, I guess I should remove the Reply-To header if I don't want direct replies. ;-)

Ciao
Dominik ^_^  ^_^
-- 
Dominik Vogt
IBM Germany
Previous: Jonathan NiederNext: Duy Nguyen
Message 8 of 11 in “Setting file timestamps to commit time (git-checkout)”
  1. Dominik VogtDec 9, 2013
  2. Junio C HamanoDec 9, 2013
  3. Dominik VogtDec 10, 2013
  4. Andreas SchwabDec 10, 2013
  5. Dominik VogtDec 11, 2013
  6. Constantine A. MureninDec 11, 2013
  7. Jonathan NiederDec 9, 2013
  8. Dominik VogtDec 10, 2013
  9. Duy NguyenDec 10, 2013
  10. Jonathan NiederDec 11, 2013
  11. Jonathan NiederDec 11, 2013

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.