{"thread":{"id":"35747","subject":"Having Git follow symlinks","startedAt":"2014-01-28T13:49:57Z","lastAt":"2014-01-31T17:56:42Z","messageCount":9,"participants":["Peter Krefting","Johan Herland","Christian Couder","Matthieu Moy","Matthew Ruffalo","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"233866","messageId":"alpine.DEB.2.02.1401281443330.17426@perkele.intern.softwolves.pp.se","threadId":"35747","inReplyTo":null,"subject":"Having Git follow symlinks","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2014-01-28T13:49:57Z","receivedAt":"2014-01-28T13:49:57Z","isPatch":false,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Hi!\n\nIs there a (per-repo) setting to get Git to follow symlinks in the \nworking directory, i.e., to not store the symlinks themselves but \nrather work on what they point to?\n\nBackground: I have a repository that stores a number of my dotfiles, \nshared between all my machines (Linux, OSX, Windows/CygWin, Solaris). \nIt is currently a CVS repo that I wish to convert to Git since CVS is \ngetting more and more scarce. However, I have the repo set up so that \nI check it out into a subdirectory of its own, and have symlinks \n(junctions on Windows) both coming into it (for files that live in ~) \nand out of it (for subdirectories of ~ that cannot be symlinks \nthemselves, such as ~/.ssh, or that live elsewhere, such as under \nAppData on Windows or ~/Library on MacOS). CVS handles this by \nsimply not knowing anything about symlinks, and I would like to \nget Git to do the same.\n\nI could probably get away with junctions on Windows and directory \nhardlinks on OSX, but that would not work on Linux.\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"233867","messageId":"CALKQrgf5o-ZcaeqXLm3P7RpK2yPcFd_HnG4ewwoEGESduyDSjQ@mail.gmail.com","threadId":"35747","inReplyTo":"alpine.DEB.2.02.1401281443330.17426@perkele.intern.softwolves.pp.se","subject":"Re: Having Git follow symlinks","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2014-01-28T14:47:14Z","receivedAt":"2014-01-28T14:47:14Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Tue, Jan 28, 2014 at 2:49 PM, Peter Krefting <peter@softwolves.pp.se> wrote:\n> Is there a (per-repo) setting to get Git to follow symlinks in the working\n> directory, i.e., to not store the symlinks themselves but rather work on\n> what they point to?\n\nNot that I know of.\n\n> Background: I have a repository that stores a number of my dotfiles, shared\n> between all my machines (Linux, OSX, Windows/CygWin, Solaris). It is\n> currently a CVS repo that I wish to convert to Git since CVS is getting more\n> and more scarce. However, I have the repo set up so that I check it out into\n> a subdirectory of its own, and have symlinks (junctions on Windows) both\n> coming into it (for files that live in ~) and out of it (for subdirectories\n> of ~ that cannot be symlinks themselves, such as ~/.ssh, or that live\n> elsewhere, such as under AppData on Windows or ~/Library on MacOS). CVS\n> handles this by simply not knowing anything about symlinks, and I would like\n> to get Git to do the same.\n\nI believe a preferable way to manage dotfiles in Git, is to have a\nscript that does the necessary setup/installation from the repo (that\nlives in some subdirectory of ~) and into ~. This script would be able\nto:\n\n - Set up whatever symlinks or copies are needed\n - Apply permission/mode bits that are not stored by Git\n - Properly handle various platform differences (symlinks vs. junctions, etc.)\n\nAs a bonus, you can run the script as a post-checkout hook, to have it\nautomatically apply any updates you fetch/push into your dotfiles\nrepo.\n\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"233939","messageId":"alpine.DEB.2.00.1401300958320.30100@ds9.cixit.se","threadId":"35747","inReplyTo":"CALKQrgf5o-ZcaeqXLm3P7RpK2yPcFd_HnG4ewwoEGESduyDSjQ@mail.gmail.com","subject":"Re: Having Git follow symlinks","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2014-01-30T09:01:20Z","receivedAt":"2014-01-30T09:01:20Z","isPatch":false,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Johan Herland:\n\n> I believe a preferable way to manage dotfiles in Git, is to have a \n> script that does the necessary setup/installation from the repo \n> (that lives in some subdirectory of ~) and into ~.\n\nYeah, but then I have copies of the files, instead of having the files \nthemselves under version control, meaning I need to copy them back to \npush changes back, or to merge them. That is undesirable :-/\n\nI do have a setup script for the CVS repo, but it just sets the \nsymlinks up.\n\n\nThe only solution I can see is to split the repo up into several \nparts, one for each sub-directory that I previously had symlinked. Not \nperfect, but I guess I can live with that.\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"233940","messageId":"CAP8UFD34r9netM_k7bG7P5NdXQnvw2OojV8X_+oYQRoKUBGYrA@mail.gmail.com","threadId":"35747","inReplyTo":"alpine.DEB.2.00.1401300958320.30100@ds9.cixit.se","subject":"Re: Having Git follow symlinks","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2014-01-30T10:09:55Z","receivedAt":"2014-01-30T10:09:55Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Thu, Jan 30, 2014 at 10:01 AM, Peter Krefting <peter@softwolves.pp.se> wrote:\n> Johan Herland:\n>\n>> I believe a preferable way to manage dotfiles in Git, is to have a script\n>> that does the necessary setup/installation from the repo (that lives in some\n>> subdirectory of ~) and into ~.\n\nThere are tools these days to manage dot files.\nSee for example:\n\nhttps://github.com/RichiH/vcsh\n\nBest,\nChristian.\n"},{"id":"233945","messageId":"vpqa9ed1w8y.fsf@anie.imag.fr","threadId":"35747","inReplyTo":"alpine.DEB.2.00.1401300958320.30100@ds9.cixit.se","subject":"Re: Having Git follow symlinks","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2014-01-30T12:37:17Z","receivedAt":"2014-01-30T12:37:17Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Peter Krefting <peter@softwolves.pp.se> writes:\n\n> Yeah, but then I have copies of the files, instead of having the files\n> themselves under version control, meaning I need to copy them back to\n> push changes back, or to merge them. That is undesirable :-/\n\nOne option is to have the symlink in the other direction: make /etc/foo\na symlink to $GIT_WORKTREE/foo and version the later.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"233971","messageId":"alpine.DEB.2.00.1401311052370.3993@ds9.cixit.se","threadId":"35747","inReplyTo":"vpqa9ed1w8y.fsf@anie.imag.fr","subject":"Re: Having Git follow symlinks","fromName":"Peter Krefting","fromEmail":"peter@softwolves.pp.se","sentAt":"2014-01-31T09:56:41Z","receivedAt":"2014-01-31T09:56:41Z","isPatch":false,"sender":{"key":"peter@softwolves.pp.se","avatar":"https://avatars.githubusercontent.com/u/990764?v=4"},"body":"Matthieu Moy:\n\n> One option is to have the symlink in the other direction: make \n> /etc/foo a symlink to $GIT_WORKTREE/foo and version the later.\n\nI do that for the software that supports it, but ssh, for instance, is \nvery picky that ~/.ssh is a directory and such. And at least one of \nthe other files I version-control will be unlinked and overwritten in \nsuch a way that that does not work.\n\nI could split the repo up (that seems to be what \"vcsh\" is doing) and \ncheck the parts out in the corresponding directories, but I do like \nthe idea of having one single repo.\n\n\nOh, well, if I have the time, maybe I can come up with a patch. There \nis already some hacks in the \"core.symlinks\" setting, so I guess it \nshould be possible.\n\n-- \n\\\\// Peter - http://www.softwolves.pp.se/\n"},{"id":"233974","messageId":"52EBA304.3000205@case.edu","threadId":"35747","inReplyTo":"alpine.DEB.2.00.1401311052370.3993@ds9.cixit.se","subject":"Re: Having Git follow symlinks","fromName":"Matthew Ruffalo","fromEmail":"mmr15@case.edu","sentAt":"2014-01-31T13:20:04Z","receivedAt":"2014-01-31T13:20:04Z","isPatch":false,"sender":{"key":"mmr15@case.edu","avatar":null},"body":"On 01/31/2014 04:56 AM, Peter Krefting wrote:\n> Matthieu Moy:\n>\n>> One option is to have the symlink in the other direction: make\n>> /etc/foo a symlink to $GIT_WORKTREE/foo and version the later.\n>\n> I do that for the software that supports it, but ssh, for instance, is\n> very picky that ~/.ssh is a directory and such. And at least one of\n> the other files I version-control will be unlinked and overwritten in\n> such a way that that does not work.\n>\n> I could split the repo up (that seems to be what \"vcsh\" is doing) and\n> check the parts out in the corresponding directories, but I do like\n> the idea of having one single repo.\n>\n>\n> Oh, well, if I have the time, maybe I can come up with a patch. There\n> is already some hacks in the \"core.symlinks\" setting, so I guess it\n> should be possible.\n>\nThis is now unrelated to Git, but I have .ssh symlinked to a\nversion-controlled directory on all of my machines (Kubuntu 13.10,\n14.04, and recent Gentoo systems, but I've also done this on CentOS 5\nand 6).\n\nSSH doesn't care whether ~/.ssh is a symlink, but it *does* //care about\npermissions:\n\n\"\"\"\nmruffalo@giygas:~$ ls -ld .ssh\nlrwxrwxrwx 1 mruffalo mruffalo 13 Mar 17  2013 .ssh -> .home-git/ssh\nmruffalo@giygas:~$ ls -ld .home-git\ndrwx------ 1 mruffalo mruffalo 116 Dec  8 01:26 .home-git\n\"\"\"\n\nIf .home-git is mode 0755, SSH may refuse to use any private keys that\nit finds, though I was unable to reproduce this with a few quick tests.\n\nMMR...\n"},{"id":"233984","messageId":"xmqq38k4hxq4.fsf@gitster.dls.corp.google.com","threadId":"35747","inReplyTo":"alpine.DEB.2.00.1401311052370.3993@ds9.cixit.se","subject":"Re: Having Git follow symlinks","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-01-31T17:23:15Z","receivedAt":"2014-01-31T17:23:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Krefting <peter@softwolves.pp.se> writes:\n\n> ...if I have the time, maybe I can come up with a patch. There is\n> already some hacks in the \"core.symlinks\" setting, so I guess it\n> should be possible.\n\nThat is totally unrelated.  The variable only says \"on this platform\nand/or filesystem, you cannot symlink(2), so instead create a\nregular file with the symlink contents when checking out a symlink\nblob\".  Most importantly, the variable does not change the fact that\nsymbolic links are explicitly tracked without dereferencing.\n\nIf you have, under a directory foo/, a symbolic link foo/bar that\npoints at \"../baz\", a directory foo/baz/, and you have a file at\nfoo/baz/hello:\n\n 1. \"git add foo\" and \"git add foo/bar\" will add foo/bar as a\n    symlink; and\n 2. \"git add foo/bar/hello\" is an error.\n\nThe variable does not have any interactions with the logic to make\nsure 2. errors out correctly, so the presense of it does not imply\nanything.\n"},{"id":"233988","messageId":"vpqiot0ox0l.fsf@anie.imag.fr","threadId":"35747","inReplyTo":"alpine.DEB.2.00.1401311052370.3993@ds9.cixit.se","subject":"Re: Having Git follow symlinks","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2014-01-31T17:56:42Z","receivedAt":"2014-01-31T17:56:42Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Peter Krefting <peter@softwolves.pp.se> writes:\n\n> Oh, well, if I have the time, maybe I can come up with a patch. There\n> is already some hacks in the \"core.symlinks\" setting, so I guess it\n> should be possible.\n\nI'd love to have a way to follow symlinks, but this needs to be done\nwith care: when following symlinks, writing to a link may mean writing\noutside the Git repository, which brings some security concerns. Not\nthat following symlinks has to be insecure, but we'd have to make sure\nthat it does not allow a malicious user to e.g. setup a symlink to\n~/.bashrc and then write to it.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}