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

Re: [PATCH] Add platform-independent .git "symlink"

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 4, 2008, 01:57 UTC
Message-ID
<20080204015707.GH24004@spearce.org>
In-Reply-To
<alpine.LSU.1.00.0802021825220.7372@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
Show 14 quoted lines
> Howver, having .git a file pointing to another git directory allows you to 
> have locks there.  And they can be actually pretty sensible locks, like
> 
> 	.git/HEAD.<mangled-path>
> 
> actually containing the symbolic ref describing which branch we're on in 
> that working directory.  Likewise, .git/index.<mangled-path> needs to hold 
> the current index.
> 
> Of course, for this to work, you need to use different HEADs and indexes 
> only if .git was a file originally.
> 
> BTW <mangled-path> could be a hash of the path, and for convenience, we 
> could store the path in .git/workdir.<mangled-path>.

This I like. Because my day-job coworkers and I make very heavy use of git-new-workdir to manage our compile areas/working directories. :)

The biggest problem with new-workdir is the master repository cannot see the HEAD, index or logs/HEAD of the working directories. Consequently it is possible for prune (or repack -a -d) to remove objects that some workdir is still referring to. Its not uncommon for my HEAD reflogs to have stale commits in them. Every once in a while a user looses their HEAD entirely when it gets pruned away, as they had a workdir checked out on a detached HEAD.

The second biggest problem is checking out the same branch in two different directories at once. This becomes a problem only if you modify the branch, but still, its a problem.

I was thinking that we could add a WORKDIR_HASH to the .git file Lars was proposing. This hash would be the <mangled-path> suffix you are talking about above, and would avoid the need to compute the absolute path for the working directory every time we run a Git command.

The hash could be something simple, like the SHA-1 hash of the absolute path at the time of workdir creation. But it would be nice if we could recommend a specific value during workdir creation, so that the WORKDIR_HASH could start with a value that matches something the user would readily recognize.

-- 
Shawn.
Previous: Johannes SchindelinNext: Junio C Hamano
Message 8 of 29 in “Add platform-independent .git "symlink"”
  1. Add platform-independent .git "symlink"Lars Hjemli, Feb 2, 2008
  2. Add tests for .git fileLars Hjemli, Feb 2, 2008
  3. Johannes SchindelinFeb 2, 2008
  4. Lars HjemliFeb 2, 2008
  5. Add platform-independent .git "symlink"Lars Hjemli, Feb 2, 2008
  6. Johannes SchindelinFeb 2, 2008
  7. Johannes SchindelinFeb 2, 2008
  8. Shawn O. PearceFeb 4, 2008
  9. Junio C HamanoFeb 4, 2008
  10. Johannes SchindelinFeb 4, 2008
  11. Brandon CaseyFeb 4, 2008
  12. Johannes SchindelinFeb 4, 2008
  13. Brandon CaseyFeb 4, 2008
  14. Johannes SchindelinFeb 4, 2008
  15. Brandon CaseyFeb 4, 2008
  16. Brandon CaseyFeb 4, 2008
  17. Johannes SchindelinFeb 5, 2008
  18. Johannes SchindelinFeb 5, 2008
  19. Brandon CaseyFeb 5, 2008
  20. Johannes SchindelinFeb 5, 2008
  21. Lars HjemliFeb 2, 2008
  22. Johannes SchindelinFeb 3, 2008
  23. Junio C HamanoFeb 4, 2008
  24. Johannes SchindelinFeb 4, 2008
  25. Shawn O. PearceFeb 4, 2008
  26. Junio C HamanoFeb 4, 2008
  27. Shawn O. PearceFeb 4, 2008
  28. Lars HjemliFeb 4, 2008
  29. Johannes SchindelinFeb 4, 2008

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.