{"thread":{"id":"26141","subject":"Bug: git add with absolute path fails if repo root dir is a symlink","startedAt":"2010-12-27T06:25:58Z","lastAt":"2010-12-27T08:13:12Z","messageCount":3,"participants":["Alexander Gladysh","Carlo Marcelo Arenas Belon"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"158611","messageId":"AANLkTi=Mj3AdinC87Ys35fv9DpZqefiZXhPbHMLdmyPh@mail.gmail.com","threadId":"26141","inReplyTo":null,"subject":"Bug: git add with absolute path fails if repo root dir is a symlink","fromName":"Alexander Gladysh","fromEmail":"agladysh@gmail.com","sentAt":"2010-12-27T06:25:58Z","receivedAt":"2010-12-27T06:25:58Z","isPatch":false,"sender":{"key":"agladysh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38239?v=4"},"body":"Hi, list.\n\nYet another issue with Git symlink handling.\n\nI can't run git add with absolute path if the repository's root\ndirectory is a symlink.\n\nPlease see the transcript below for details.\n\nAlexander.\n\n$ lsb_release -a\nNo LSB modules are available.\nDistributor ID:\tUbuntu\nDescription:\tUbuntu 10.10\nRelease:\t10.10\nCodename:\tmaverick\n\n$ uname -a\nLinux ubuntu 2.6.35-24-generic #42-Ubuntu SMP Thu Dec 2 01:41:57 UTC\n2010 i686 GNU/Linux\n\n$ git --version\ngit version 1.7.3.4\n\n$ mkdir myrepo && cd myrepo\n$ git init\n$ touch alpha\n$ git add alpha\n$ git commit -m \"initial commit\"\n\n$ cd ../\n$ ln -s myrepo mysymlink\n$ cd mysymlink\n$ git status\n$ touch beta\n\n$ git add ~/tmp/git-test/mysymlink/beta\nfatal: '/home/agladysh/tmp/git-test/mysymlink/beta' is outside repository\n\n$ cd ../myrepo/\n$ git add ~/tmp/git-test/myrepo/beta\n$ git status\n# On branch master\n# Changes to be committed:\n#   (use \"git reset HEAD <file>...\" to unstage)\n#\n#\tnew file:   beta\n#\n"},{"id":"158612","messageId":"AANLkTimPxhqwMebfTw9oHucuvABmSBynpZgG1zp6uwVz@mail.gmail.com","threadId":"26141","inReplyTo":"AANLkTi=Mj3AdinC87Ys35fv9DpZqefiZXhPbHMLdmyPh@mail.gmail.com","subject":"Re: Bug: git add with absolute path fails if repo root dir is a symlink","fromName":"Alexander Gladysh","fromEmail":"agladysh@gmail.com","sentAt":"2010-12-27T07:23:12Z","receivedAt":"2010-12-27T07:23:12Z","isPatch":false,"sender":{"key":"agladysh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38239?v=4"},"body":"On Mon, Dec 27, 2010 at 09:25, Alexander Gladysh <agladysh@gmail.com> wrote:\n\n> I can't run git add with absolute path if the repository's root\n> directory is a symlink.\n\nNote that this issue is also triggered if *any* of the directories in\npath above of my repo are symlinks.\n\nThis is a show-stopper for my current workflow.\n\nIs there a way to quickly workaround this somehow?\n\nAlexander.\n"},{"id":"158614","messageId":"20101227081312.GA12735@sajinet.com.pe","threadId":"26141","inReplyTo":"AANLkTimPxhqwMebfTw9oHucuvABmSBynpZgG1zp6uwVz@mail.gmail.com","subject":"Re: Bug: git add with absolute path fails if repo root dir is a symlink","fromName":"Carlo Marcelo Arenas Belon","fromEmail":"carenas@sajinet.com.pe","sentAt":"2010-12-27T08:13:12Z","receivedAt":"2010-12-27T08:13:12Z","isPatch":false,"sender":{"key":"carenas@sajinet.com.pe","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"On Mon, Dec 27, 2010 at 10:23:12AM +0300, Alexander Gladysh wrote:\n> \n> > I can't run git add with absolute path if the repository's root\n> > directory is a symlink.\n> \n> Note that this issue is also triggered if *any* of the directories in\n> path above of my repo are symlinks.\n\nWhen using absolute path names, git will compare the path given with the\ngit work tree and any name that is referred through a symlink in that\nwill trigger a mismatch.\n\n> Is there a way to quickly workaround this somehow?\n\nuse relative paths (implemented below through an alias named \"myadd\") :\n\n[alias]\n        myadd = \"!sh -c 'cd `dirname \\\"$1\\\"` && git add `basename \\\"$1\\\"`' -\"\n\nso in your workflow you would use \"myadd\" instead of \"add\" to convert your\nabsolute paths (with symlinks) into relative paths\n\nCarlo\n"}]}