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

Re: Git checkout preserve timestamp?

From
SCSergio Callegari <scallegari@arces.unibo.it>
Date
Mar 6, 2007, 18:39 UTC
Message-ID
<loom.20070306T190954-291@post.gmane.org>
In-Reply-To
<7vodn7w6rz.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio <at> cox.net> writes:
Show 27 quoted lines
> 
> Michael Poole <mdpoole <at> troilus.org> writes:
> 
> > This all sounds a lot like git-clone's "alternate" code.
> > ...
> > My own work habits are very similar to Bill Lear's, but my projects'
> > build times are small enough that it's less pain to rebuild half the
> > project than to propagate changes recorded under $GIT_DIR between
> > local branches.  I have not found a git workflow that makes me
> > entirely happy, but I suspect I just don't know the magic words.
> 
> These days I use a few working trees that are connected to my
> primary repository (which also has a working tree).  The primary
> repository is in /src/git, and other ones look like this:
> 
> : gitster git.wk0; ls -l .git/
> total 120
> drwxrwsr-x  3 junio src  4096 Mar  5 16:22 ./
> drwxrwsr-x 15 junio src 16384 Mar  5 16:23 ../
> -rw-rw-r--  1 junio src    41 Mar  5 16:22 HEAD
> lrwxrwxrwx  1 junio src    27 Mar  3 22:53 config -> /src/git/.git/config
> lrwxrwxrwx  1 junio src    26 Mar  3 22:53 hooks -> /src/git/.git/hooks/
> -rw-rw-r--  1 junio src 82455 Mar  5 16:22 index
> lrwxrwxrwx  1 junio src    25 Mar  3 22:53 info -> /src/git/.git/info/
> drwxrwsr-x  3 junio src  4096 Mar  3 22:59 logs/
> lrwxrwxrwx  1 junio src    28 Mar  3 22:53 objects -> /src/git/.git/objects/
> lrwxrwxrwx  1 junio src    32 Mar  3 22:53 packed-refs ->
/src/git/.git/packed-refs
Show 20 quoted lines
> lrwxrwxrwx  1 junio src    25 Mar  3 22:53 refs -> /src/git/.git/refs/
> lrwxrwxrwx  1 junio src    28 Mar  3 22:53 remotes -> /src/git/.git/remotes/
> lrwxrwxrwx  1 junio src    29 Mar  3 22:53 rr-cache -> /src/git/.git/rr-cache/
> 
> It shares everything other than HEAD and the index (the reflog
> for branches are also shared by a symlink .git/logs/refs
> pointing at the one in the primary repository).
> 
> This risks confusion for an uninitiated if you update a ref that
> is checked out in another working tree, but modulo that caveat
> it works reasonably well.
> 
> We might want to add an option to 'git-clone' to create
> something like this, but I am somewhat worried about the newbie
> confusion factor.  Perhaps...
> 
> $ git clone --i-know-what-i-am-doing-give-me-an-alternate-working-tree \
>   /src/git /src/git.wk0
> 
> 

This looks very much like the .gitlink approach that was previously proposed on the list, I think...

In that proposal, rather than having many symlinks in the .git repo, you would have a single .gitlink one... (plus, obviously a live index and HEAD). Possibly, the .gitlink approach could be better, since in case the *real* repo needs for some reason to be moved, then you just need to update a single link rather than many of them (this might also be safer... just imagine a scenario where one updates the links by hand and forgets to update one of them... and more friendly to OSes disliking symbolic links).

You mention the fact that the only possible confusion here is if a ref that is checked out in another working tree gets updated... Something like I update master on WT A, but another WT B has master checked out, so the status of the WT in B gets old with regard to the new branch tip... I guess that in this case committing in WT B could be a disaster...

However, if in HEAD we stored not just the branch-ref, but also its commit ID this case could become very easy to spot... and we could start behaving as if we were headless... (possibly safer)... or am I completely wrong?

Sergio
Previous: Junio C HamanoNext: Jakub Narebski
Message 33 of 51 in “Git checkout preserve timestamp?”
  1. Bill LearMar 1, 2007
  2. Alex RiesenMar 1, 2007
  3. Johannes SchindelinMar 1, 2007
  4. Linus TorvaldsMar 1, 2007
  5. Johannes SchindelinMar 1, 2007
  6. Karl HasselströmMar 2, 2007
  7. Bill LearMar 2, 2007
  8. Bart TrojanowskiMar 2, 2007
  9. Johannes SchindelinMar 2, 2007
  10. Karl HasselströmMar 2, 2007
  11. Johannes SchindelinMar 2, 2007
  12. Karl HasselströmMar 5, 2007
  13. Johannes SchindelinMar 5, 2007
  14. Karl HasselströmMar 5, 2007
  15. Bill LearMar 5, 2007
  16. Johannes SchindelinMar 5, 2007
  17. Bill LearMar 5, 2007
  18. Johannes SchindelinMar 5, 2007
  19. Bill LearMar 5, 2007
  20. Linus TorvaldsMar 5, 2007
  21. Matthieu MoyMar 5, 2007
  22. Bill LearMar 5, 2007
  23. Linus TorvaldsMar 5, 2007
  24. Bill LearMar 5, 2007
  25. Johannes SchindelinMar 5, 2007
  26. Bill LearMar 5, 2007
  27. Johannes SchindelinMar 5, 2007
  28. Michael PooleMar 6, 2007
  29. Johannes SchindelinMar 6, 2007
  30. Michael PooleMar 6, 2007
  31. Johannes SchindelinMar 6, 2007
  32. Junio C HamanoMar 6, 2007
  33. Sergio CallegariMar 6, 2007
  34. Jakub NarebskiMar 6, 2007
  35. Bill LearMar 6, 2007
  36. Johannes SchindelinMar 6, 2007
  37. Bill LearMar 6, 2007
  38. Martin LanghoffMar 6, 2007
  39. Theodore TsoMar 6, 2007
  40. Matthieu MoyMar 5, 2007
  41. Johannes SchindelinMar 5, 2007
  42. Bill LearMar 5, 2007
  43. Johannes SchindelinMar 5, 2007
  44. Bill LearMar 5, 2007
  45. Andy ParkinsMar 5, 2007
  46. Karl HasselströmMar 5, 2007
  47. Andy ParkinsMar 5, 2007
  48. Karl HasselströmMar 5, 2007
  49. Bill LearMar 5, 2007
  50. Andy ParkinsMar 5, 2007
  51. Bill LearMar 5, 2007

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.