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:35 UTC
Message-ID
<20131210083531.GB4087@linux.vnet.ibm.com>
In-Reply-To
<xmqqsiu1yd7p.fsf@gitster.dls.corp.google.com>
On Mon, Dec 09, 2013 at 12:35:38PM -0800, Junio C Hamano wrote:
Show 17 quoted lines
> Dominik Vogt <vogt@linux.vnet.ibm.com> writes:
> 
> > Me and some colleagues work on gcc in lots of different branches.
> > For each branch there is a separate build directory for each
> > branch, e.g. build-a, build-b and build-c.  Let's assume that all
> > branches are identical at the moment.  If a file in branch a is
> > changed that triggers a complete rebuild of gcc (e.g.
> > <target>.opt), rebuilding in build-a takes about an hour.  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 am not quite sure I follow your set-up.  Do you have three working
> trees connected to a repository (via contrib/workdir/git-new-workdir
> perhaps), each having a checkout of its own branch?

No, just one working tree, but three separate build directories for various branches. Actually, the build directories could be located at some random place on disk, but it's convenient to keep them inside the working tree. Personally I do not use multiple working trees because in the past I had the impression that this kind of setup creates more problems than it solves. Just to give you an idea how my current workspace looks like:

  ~/rpm/BUILD/gcc-4.1.2-20080825
    build-4.1/
    install-4.1/
    ...
  (branch "master")
  ~/rpm/BUILD/gcc-4.4.7-20120601
    build-4.4/
    install-4.1/
  (branch "master")
  ~/src/git/gcc-unpatched
    build/
    install/
    ...
  (branch "master")
  ~/src/git/gcc-patched
    build-4.8/
    build-4.9/
    build-somefeature/
    install-4.8/
    install-4.9/
    install-somefeature/
    ...
  (various feature branches)
> [snip]
Hm, the case I described was too simple.  Another try:
* With the setup described above I have, say, eleven branches, namely
  a and b, b2, ..., b9:
  ---o---X     <== a
     |
     `---Y     <== b
         |
         |---o <== b2
         ...
         `---o <== b9
* The two commits X and Y both touch a file that triggers a
  complete rebuild, say gcc/common.opt.
* Each branch has a matching build directory build-<branch>, and
  all of them are built for the latest version of the
  corresponding branch.
* Switch to branch a and do some work or just look at it.
* When I switch back to any of the b-branches, gcc/common.opt gets
  stamped with the current time, i.e. "make" considers the whole
  build directory to be outdated and builds everything from
  scratch.  Then I switch to another b-branch and the whole thing
  starts over etc.  With gcc-bootstrapping enabled, such a build
  takes me almost an hour.  In other words, just looking at branch
  a entails a full day just rebuilding branches that have not
  changed at all.

I've discussed that with some of my co-workers, but we still could not come up with a nice solution. The "right" way to "fix" this might be to stash all file modification dates on a branch switch and restore them when switching back to the original. But that sounds awfully expensive, and really out of the scope of an RCS. The second best approach I could think of is to stamp files with the timestamp of the last commit that touched that, but I guess that is not a cheap operation either.

Ciao
Dominik ^_^  ^_^
-- 
Dominik Vogt
IBM Germany
Previous: Junio C HamanoNext: Andreas Schwab
Message 3 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.