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

Re: git and symlinks as tracked content

From
Junio C Hamano <junkio@cox.net>
Date
May 3, 2005, 20:23 UTC
Message-ID
<7vy8awt5wo.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.58.0505031151240.26698@ppc970.osdl.org>
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> On Tue, 3 May 2005, Kay Sievers wrote:
>> Where can we store the link-target? In its own blob-object or directly
>> in the tree-object?

LT> - directories: S_IFDIR (0040000) point to "tree" objects for contents LT> - symlinks: S_IFLNK (0120000) point to "blob" objects LT> - executables: S_IFREG | 0755 (0100755) point to "blob" objects LT> - regular files: S_IFREG | 0644 (0100644) point to "blob" objects

These and the device nodes you mention would work naturally on the cache side and I generally like this idea. You need to update checkout-cache to (attempt to) create the right kind of file, but that is about it.

On the diff side, things are a bit more interesting. Both the git-diff-tree-helper engine (diff.c) and git-apply-patch-script need to be told about these new types of objects, or at least tightened up to ignore them until they know how to support them.

LT> When you think of it that way, the "patch" ends up falling out very LT> naturally, I think. It would look like

LT> New file: filename (Mode: 0120000) LT> --- /dev/null LT> +++ filename LT> @@ 0,0 1,1 LT> +symlink-value

LT> (or something, you get the idea).

I've always wanted to have this from the normal "diff -r" output, but we have to be careful. You do not want to accidentally feed the normal patch that kind of output. How about doing something like this?

GIT: filename (mode:120000)
 --- /dev/null
 +++ filename
 @@ -0,0 +1 @@
 +symlink-value
GIT: filename (mode:120000)
 --- filename
 +++ /dev/null
 @@ -1 +0,0 @@
 -symlink-value
GIT: filename (mode:120000->120000)
 --- filename
 +++ filename
 @@ -1 +1 @@
 -old-symlink-value
 +new-symlink-value
That is, to indent them to keep patch from noticing them [*1*].

About the device nodes, the diffed contents would be major and minor in decimal notation, and the real filesystem permission bits and ownerships (e.g. changing /dev/audio from 0600 to 0660 or from root:root to root:audio). I do not know if we would want owner/group in symbolic or numeric yet.

GIT: filename (mode:0020000->0020000)
 --- dev/audio
 +++ dev/audio
 @@ -1,5 +1,5 @@
  major=14
  minor=4
  owner=root
 -group=root
 -perm=0600
 +group=audio
 +perm=0660
[Footnote]

*1* A careful but not careful enough reader would wonder if the use of "--- /dev/null" or "+++ /dev/null" to represent an addition and a deletion may hamper managing the device node "/dev/null", but this is not a problem. Such a device node managed by GIT will appear as "--- dev/null" or "+++ dev/null", without the leading slash.

Previous: Daniel BarkalowNext: Kay Sievers
Message 24 of 29 in “git and symlinks as tracked content”
  1. Kay SieversMay 3, 2005
  2. Linus TorvaldsMay 3, 2005
  3. Morten WelinderMay 3, 2005
  4. H. Peter AnvinMay 3, 2005
  5. Andreas GalMay 3, 2005
  6. Linus TorvaldsMay 3, 2005
  7. Kay SieversMay 3, 2005
  8. Junio C HamanoMay 3, 2005
  9. Andreas GalMay 3, 2005
  10. Junio C HamanoMay 3, 2005
  11. Sym-links, b/c-special files, pipes, ... Scope CreepBrian O'Mahoney, May 4, 2005
  12. H. Peter AnvinMay 3, 2005
  13. Junio C HamanoMay 3, 2005
  14. H. Peter AnvinMay 3, 2005
  15. Linus TorvaldsMay 3, 2005
  16. Junio C HamanoMay 3, 2005
  17. David A. WheelerMay 4, 2005
  18. Daniel BarkalowMay 4, 2005
  19. Alan ChandlerMay 5, 2005
  20. read-only git repositoriesDavid Lang, May 5, 2005
  21. SeanMay 5, 2005
  22. David A. WheelerMay 6, 2005
  23. Daniel BarkalowMay 5, 2005
  24. Junio C HamanoMay 3, 2005
  25. Kay SieversMay 4, 2005
  26. Junio C HamanoMay 4, 2005
  27. Kay SieversMay 5, 2005
  28. Junio C HamanoMay 5, 2005
  29. Kay SieversMay 5, 2005

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.