{"thread":{"id":"34550","subject":"[BUG] git_path() returns relative paths","startedAt":"2013-07-27T11:10:12Z","lastAt":"2013-07-28T09:24:49Z","messageCount":18,"participants":["Ramkumar Ramachandra","Duy Nguyen","Fredrik Gustafsson","Jiang Xin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"224174","messageId":"CALkWK0m-4wtpTAcePPWFLT7iwXdcpp+nOy9oG2iFHLsp9XdKZQ@mail.gmail.com","threadId":"34550","inReplyTo":null,"subject":"[BUG] git_path() returns relative paths","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-27T11:10:12Z","receivedAt":"2013-07-27T11:10:12Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nI noticed a regression in the latest master, and I've been trying to\ndebug it for 30 minutes now.  I'm still clueless about the root cause,\nbut I'll list whatever I found so far:\n\nI suddenly noticed that I wasn't able to commit to a certain\nrepository with submodules anymore.  This was because git commit was\nopening a COMMIT_EDITMSG in the wrong path.  To reproduce the problem,\nyou need a setup like mine:\n\n  ~/dotfiles is a repository containing submodules\n  ~/.elisp is a symbolic link to ~/dotfiles/.elisp, a normal directory\n  ~/.elisp/flx is the submodule repository to which I'm trying to commit\n\nThe buffer-file-name of COMMIT_EDITMSG comes out as\n/home/artagnon/.git/modules/flx/.git/COMMIT_EDITMSG, which is\ncompletely wrong because ~ does not even contain a .git.\n\nSo, I started debugging the issue with this patch:\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 003bd7d..38a7c77 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -678,6 +678,9 @@ static int prepare_to_commit(const char\n                hook_arg2 = \"\";\n        }\n\n+       char *buf = get_current_dir_name();\n+       die(\"DBG: %s | %s\", buf, git_path(commit_editmsg));\n+\n        s->fp = fopen(git_path(commit_editmsg), \"w\");\n        if (s->fp == NULL)\n                die_errno(_(\"could not open '%s'\"), git_path(commit_editmsg));\n\nOn master, commit returns:\n\n  fatal: DBG: /home/artagnon/.elisp/flx |\n../../.git/modules/.elisp/flx/COMMIT_EDITMSG\n\nWhen backported to v1.8.3.3, commit returns:\n\n  fatal: DBG: /home/artagnon/.elisp/flx |\n/home/artagnon/dotfiles/.git/modules/.elisp/flx/COMMIT_EDITMSG\n\nI tried looking through the logs to see what has changed in\npath.c/environment.c, but have come up with nothing so far.  I think\nI'll have to resort to using a hammer like bisect now.\n\n*scratches head*\n"},{"id":"224177","messageId":"CACsJy8B24FL8OriirWnxDb7rGJorn357rnqf709rOUDTdfUGCw@mail.gmail.com","threadId":"34550","inReplyTo":"CALkWK0m-4wtpTAcePPWFLT7iwXdcpp+nOy9oG2iFHLsp9XdKZQ@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-07-27T11:48:38Z","receivedAt":"2013-07-27T11:48:38Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Jul 27, 2013 at 6:10 PM, Ramkumar Ramachandra\n<artagnon@gmail.com> wrote:\n> I tried looking through the logs to see what has changed in\n> path.c/environment.c, but have come up with nothing so far.  I think\n> I'll have to resort to using a hammer like bisect now.\n>\n> *scratches head*\n\nTry bisect with GIT_TRACE_SETUP=2 and watch \"setup: git_dir: \" line.\nAlthough $GIT_DIR can be relative and so can git_path(), there may be\nsomething else that leads to wrong result path.\n-- \nDuy\n"},{"id":"224178","messageId":"CALkWK0k-23rTohYvNWP_XbuUCSGUE+G_e_7cBbPP5C9OzsJ4XQ@mail.gmail.com","threadId":"34550","inReplyTo":"CALkWK0m-4wtpTAcePPWFLT7iwXdcpp+nOy9oG2iFHLsp9XdKZQ@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-27T12:05:36Z","receivedAt":"2013-07-27T12:05:36Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Ramkumar Ramachandra wrote:\n> *scratches head*\n\nJust took a much-needed shower and came back.  It was trivial to find.\n\n  $ git log v1.8.3.4.. -- path.c\n\ne02ca72 (path.c: refactor relative_path(), not only strip prefix,\n2013-06-25) is the offender.\n"},{"id":"224180","messageId":"20130727121406.GB4940@paksenarrion.iveqy.com","threadId":"34550","inReplyTo":"CALkWK0m-4wtpTAcePPWFLT7iwXdcpp+nOy9oG2iFHLsp9XdKZQ@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2013-07-27T12:14:06Z","receivedAt":"2013-07-27T12:14:06Z","isPatch":false,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"On Sat, Jul 27, 2013 at 04:40:12PM +0530, Ramkumar Ramachandra wrote:\n> Hi,\n> \n> I noticed a regression in the latest master, and I've been trying to\n> debug it for 30 minutes now.  I'm still clueless about the root cause,\n> but I'll list whatever I found so far:\n> \n> I suddenly noticed that I wasn't able to commit to a certain\n> repository with submodules anymore.  This was because git commit was\n> opening a COMMIT_EDITMSG in the wrong path.  To reproduce the problem,\n> you need a setup like mine:\n\nWhen I hear submodules, latest master and path the only thing that comes\nto my mind that have touched these areas is\n091a6eb0feed820a43663ca63dc2bc0bb247bbae \"submodule: drop the top-level\nrequirement\".\n\nA first test could be to see if it's this patch does anything strange.\nHowever this patch is in git since 1.8.3.3 so it's almost a month old.\n\n-- \nMed vänliga hälsningar\nFredrik Gustafsson\n\ntel: 0733-608274\ne-post: iveqy@iveqy.com\n"},{"id":"224181","messageId":"CALkWK0kBesC2=kyygMCt61Fm5GGqX+yF6sbkCRcGYZ=ovgtTAQ@mail.gmail.com","threadId":"34550","inReplyTo":"CALkWK0k-23rTohYvNWP_XbuUCSGUE+G_e_7cBbPP5C9OzsJ4XQ@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-27T12:31:53Z","receivedAt":"2013-07-27T12:31:53Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Ramkumar Ramachandra wrote:\n> e02ca72 (path.c: refactor relative_path(), not only strip prefix,\n> 2013-06-25) is the offender.\n\nThe problem is the callsite in setup.c:setup_work_tree(). When\nrelative_path() is called with\n\"/home/artagnon/dotfiles/.git/modules/.elisp/flx\" and\n\"/home/artagnon/dotfiles/.elisp/flx\" as the first and second\narguments, it sets sb to \"../../.git/modules/.elisp/flx\".\n\nMakes me wonder why setup_git_dir() doesn't just use git_dir; why does\nit need a relative path at all?\n"},{"id":"224182","messageId":"CACsJy8C5Du8zcqVeN7EGuyUxgSZaRq-X8y_hQvqQedYWfP8p+A@mail.gmail.com","threadId":"34550","inReplyTo":"CALkWK0kBesC2=kyygMCt61Fm5GGqX+yF6sbkCRcGYZ=ovgtTAQ@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-07-27T12:47:28Z","receivedAt":"2013-07-27T12:47:28Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Jul 27, 2013 at 7:31 PM, Ramkumar Ramachandra\n<artagnon@gmail.com> wrote:\n> Ramkumar Ramachandra wrote:\n>> e02ca72 (path.c: refactor relative_path(), not only strip prefix,\n>> 2013-06-25) is the offender.\n>\n> The problem is the callsite in setup.c:setup_work_tree(). When\n> relative_path() is called with\n> \"/home/artagnon/dotfiles/.git/modules/.elisp/flx\" and\n> \"/home/artagnon/dotfiles/.elisp/flx\" as the first and second\n> arguments, it sets sb to \"../../.git/modules/.elisp/flx\".\n>\n> Makes me wonder why setup_git_dir() doesn't just use git_dir; why does\n> it need a relative path at all?\n\n044bbbc (Make git_dir a path relative to work_tree in\nsetup_work_tree() - 2008-06-19)\n-- \nDuy\n"},{"id":"224183","messageId":"CALkWK0kx7NwzsC1-2JYwxjykMkCwz8RZ=y3LqjkQWB6tuOWNtA@mail.gmail.com","threadId":"34550","inReplyTo":"20130727121406.GB4940@paksenarrion.iveqy.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-27T13:26:17Z","receivedAt":"2013-07-27T13:26:17Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Fredrik Gustafsson wrote:\n> When I hear submodules\n\nThe only reason this bug has something to do with submodules is\nbecause of the relative path in the gitfile (although I'm yet to\ncorner the exact issue).  Otherwise, it doesn't exercise any new code\nin submodule.c/ git-submodule.sh.\n"},{"id":"224184","messageId":"CALkWK0kWnge7fVtTXRgTiK1NbyN8X=bmqfPTc+Mp=BCssPc1og@mail.gmail.com","threadId":"34550","inReplyTo":"CACsJy8C5Du8zcqVeN7EGuyUxgSZaRq-X8y_hQvqQedYWfP8p+A@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-27T14:33:14Z","receivedAt":"2013-07-27T14:33:14Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Duy Nguyen wrote:\n> 044bbbc (Make git_dir a path relative to work_tree in\n> setup_work_tree() - 2008-06-19)\n\nOkay, so it does seem to be a significant optimization.  Frankly,\ne02ca72 only improves the relative_path() algorithm, and it's not\nreally doing anything Wrong: it's has just uncovered a previously\nundiscovered bug.\n\nSo far, we know that the line:\n\n  s->fp = fopen(git_path(commit_editmsg), \"w\");\n\nin commit.c:prepare_to_commit() isn't failing; so, the work_tree and\ngit_dir do seem to be set correctly. The problem seems to be in\nlaunch_editor().  What's worse? Everything works just fine when I have\na symbolic link to a directory in a normal repository; I still can't\nfigure out what submodules have to do with any of this.\n\nWhat the hell is going on?!\n"},{"id":"224185","messageId":"CACsJy8CDg2ORKrpwiph=WdW5GPUYEwT1CSCttQ4fagQoMP4QGA@mail.gmail.com","threadId":"34550","inReplyTo":"CALkWK0kWnge7fVtTXRgTiK1NbyN8X=bmqfPTc+Mp=BCssPc1og@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-07-27T15:17:17Z","receivedAt":"2013-07-27T15:17:17Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Jul 27, 2013 at 9:33 PM, Ramkumar Ramachandra\n<artagnon@gmail.com> wrote:\n> Duy Nguyen wrote:\n>> 044bbbc (Make git_dir a path relative to work_tree in\n>> setup_work_tree() - 2008-06-19)\n>\n> Okay, so it does seem to be a significant optimization.  Frankly,\n> e02ca72 only improves the relative_path() algorithm, and it's not\n> really doing anything Wrong: it's has just uncovered a previously\n> undiscovered bug.\n>\n> So far, we know that the line:\n>\n>   s->fp = fopen(git_path(commit_editmsg), \"w\");\n>\n> in commit.c:prepare_to_commit() isn't failing; so, the work_tree and\n> git_dir do seem to be set correctly. The problem seems to be in\n> launch_editor().  What's worse? Everything works just fine when I have\n> a symbolic link to a directory in a normal repository; I still can't\n> figure out what submodules have to do with any of this.\n>\n> What the hell is going on?!\n\nI was involved with this code (the gitdir setup code, not submodule)\nand am interested to know what's going on too. Could you produce a\nsmall script to reproduce it?\n-- \nDuy\n"},{"id":"224187","messageId":"CALkWK0=xuNGM54=Kodfi9L8_yUOaXrWvqiMHbx2SRTH1CmZxLA@mail.gmail.com","threadId":"34550","inReplyTo":"CACsJy8CDg2ORKrpwiph=WdW5GPUYEwT1CSCttQ4fagQoMP4QGA@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-27T16:05:40Z","receivedAt":"2013-07-27T16:05:40Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Duy Nguyen wrote:\n> I was involved with this code (the gitdir setup code, not submodule)\n> and am interested to know what's going on too. Could you produce a\n> small script to reproduce it?\n\nHere's your reduced testcase. Just point mygit to a HEAD build.\n\n  #!/bin/sh\n\n  mygit=~/src/git/git\n  cd /tmp\n  $mygit clone https://github.com/artagnon/clayoven\n  cd clayoven\n  $mygit submodule add https://github.com/lewang/flx .elisp/flx\n  $mygit commit -a -m \"Added submodule\"\n  cd /tmp\n  ln -s clayoven/.elisp\n  cd .elisp/flx\n  EDITOR=\"emacs -Q\" git commit --amend\n  # buffer-file-name = \"/tmp/.git/modules/.elisp/flx/COMMIT_EDITMSG\"\n\nNote that this is emacs 24.3. I used -Q to make sure that none of my\ninit magic (magit etc.) was responsible for changing directories or\ndoing something equally stupid. However, considering that it's\nimpossible to reproduce the problem with either cat or vim as the\nEDITOR, you might be inclined to classify this as an Emacs bug. In\nthat case, why can't I reproduce it without submodules?\n\nI'm going off to eat cake before I tear my hair out in frustration.\n"},{"id":"224192","messageId":"CANYiYbEiE+S3J3MR=YyK8Tn48zfmhzJjBjnuPtxzd6WtBU8duA@mail.gmail.com","threadId":"34550","inReplyTo":"CALkWK0=xuNGM54=Kodfi9L8_yUOaXrWvqiMHbx2SRTH1CmZxLA@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2013-07-27T23:25:43Z","receivedAt":"2013-07-27T23:25:43Z","isPatch":false,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"2013/7/28 Ramkumar Ramachandra <artagnon@gmail.com>:\n> Duy Nguyen wrote:\n>> I was involved with this code (the gitdir setup code, not submodule)\n>> and am interested to know what's going on too. Could you produce a\n>> small script to reproduce it?\n>\n> Here's your reduced testcase. Just point mygit to a HEAD build.\n>\n>   #!/bin/sh\n>\n>   mygit=~/src/git/git\n>   cd /tmp\n>   $mygit clone https://github.com/artagnon/clayoven\n>   cd clayoven\n>   $mygit submodule add https://github.com/lewang/flx .elisp/flx\n>   $mygit commit -a -m \"Added submodule\"\n>   cd /tmp\n>   ln -s clayoven/.elisp\n>   cd .elisp/flx\n>   EDITOR=\"emacs -Q\" git commit --amend\n\nThe keypoint is that you set GIT_EDITOR to \"emacs -Q\". Last night\nI can not reproduce the bug, because I use vim as the editor.\nVim as a editor may call realpath before open file.\n\nI change the EDITOR(GIT_EDITOR) environment in your test script\nas follows:\n\n    GIT_EDITOR=\"echo PWD: $(pwd); echo REALPATH: $(pwd -P); echo\" \\\n    git commit --amend\n\nAnd the result is :\n\n    PWD: /tmp/.elisp/flx\n    REALPATH: /private/tmp/clayoven/.elisp/flx\n    ../../.git/modules/.elisp/flx/COMMIT_EDITMSG\n    [master 248e49e] add usage information\n     Author: Le Wang <le.wang@agworld.com.au>\n     1 file changed, 27 insertions(+)\n\nHow to fix this bug, I have no idea now.\n\n-- \nJiang Xin\n"},{"id":"224193","messageId":"CALkWK0=FA0g9W7T4=qULJS+FN=WduA3jDmpSq01xayr9SsncgA@mail.gmail.com","threadId":"34550","inReplyTo":"CANYiYbEiE+S3J3MR=YyK8Tn48zfmhzJjBjnuPtxzd6WtBU8duA@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-28T00:03:12Z","receivedAt":"2013-07-28T00:03:12Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Jiang Xin wrote:\n> I change the EDITOR(GIT_EDITOR) environment in your test script\n> as follows:\n>\n>     GIT_EDITOR=\"echo PWD: $(pwd); echo REALPATH: $(pwd -P); echo\" \\\n>     git commit --amend\n\nSee, what stumps be about this is the no-submodule case:\n\n  #!/bin/sh\n\n  mygit=~/src/git/git\n  cd /tmp\n  rm -rf clayoven lib\n  $mygit clone https://github.com/artagnon/clayoven\n  ln -s clayoven/lib\n  cd lib/clayoven\n  EDITOR=\"echo PWD: $(pwd); echo REALPATH: $(pwd -P); echo\" \\\n  git commit --amend\n  # buffer-file-name = \"/tmp/.git/modules/.elisp/flx/COMMIT_EDITMSG\"\n\n>From the point of view of $EDITOR, how is this different?  Yet, when\nyou change EDITOR to \"emacs -Q\", it works fine.\n"},{"id":"224195","messageId":"CACsJy8AuAy7PnEU20k23gVRQoFrLhJrM6hfESZKshUA578c3Ew@mail.gmail.com","threadId":"34550","inReplyTo":"CALkWK0=xuNGM54=Kodfi9L8_yUOaXrWvqiMHbx2SRTH1CmZxLA@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-07-28T04:37:55Z","receivedAt":"2013-07-28T04:37:55Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Jul 27, 2013 at 11:05 PM, Ramkumar Ramachandra\n<artagnon@gmail.com> wrote:\n> Here's your reduced testcase. Just point mygit to a HEAD build.\n>\n>   #!/bin/sh\n>\n>   mygit=~/src/git/git\n>   cd /tmp\n>   $mygit clone https://github.com/artagnon/clayoven\n>   cd clayoven\n>   $mygit submodule add https://github.com/lewang/flx .elisp/flx\n>   $mygit commit -a -m \"Added submodule\"\n>   cd /tmp\n>   ln -s clayoven/.elisp\n>   cd .elisp/flx\n>   EDITOR=\"emacs -Q\" git commit --amend\n>   # buffer-file-name = \"/tmp/.git/modules/.elisp/flx/COMMIT_EDITMSG\"\n\nHere cwd is /tmp/.elisp/flx but \"setup: cwd: \" returns\n/tmp/clayoven/.elisp/flx. The COMMIT_EDITMSG path is\n../../.git/modules/.elisp/flx/COMMIT_EDITMSG. If you follow the former\ncwd (without symlink resolution), you end up at /tmp/.git/modules. If\nyou follow the latter cwd, you end up at /tmp/clayoven/.git/modules...\nI think instead of letting the kernel walk the path, emacs does it by\nitself. Still looking for documents about this behavior..\n\n> Note that this is emacs 24.3. I used -Q to make sure that none of my\n> init magic (magit etc.) was responsible for changing directories or\n> doing something equally stupid. However, considering that it's\n> impossible to reproduce the problem with either cat or vim as the\n> EDITOR, you might be inclined to classify this as an Emacs bug. In\n> that case, why can't I reproduce it without submodules?\n>\n> I'm going off to eat cake before I tear my hair out in frustration.\n-- \nDuy\n"},{"id":"224197","messageId":"20130728050009.GA10844@lanh","threadId":"34550","inReplyTo":"CALkWK0=xuNGM54=Kodfi9L8_yUOaXrWvqiMHbx2SRTH1CmZxLA@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-07-28T05:00:09Z","receivedAt":"2013-07-28T05:00:09Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Jul 27, 2013 at 09:35:40PM +0530, Ramkumar Ramachandra wrote:\n> Duy Nguyen wrote:\n> > I was involved with this code (the gitdir setup code, not submodule)\n> > and am interested to know what's going on too. Could you produce a\n> > small script to reproduce it?\n> \n> Here's your reduced testcase. Just point mygit to a HEAD build.\n> \n>   #!/bin/sh\n> \n>   mygit=~/src/git/git\n>   cd /tmp\n>   $mygit clone https://github.com/artagnon/clayoven\n>   cd clayoven\n>   $mygit submodule add https://github.com/lewang/flx .elisp/flx\n>   $mygit commit -a -m \"Added submodule\"\n>   cd /tmp\n>   ln -s clayoven/.elisp\n>   cd .elisp/flx\n>   EDITOR=\"emacs -Q\" git commit --amend\n>   # buffer-file-name = \"/tmp/.git/modules/.elisp/flx/COMMIT_EDITMSG\"\n> \n> Note that this is emacs 24.3. I used -Q to make sure that none of my\n> init magic (magit etc.) was responsible for changing directories or\n> doing something equally stupid. However, considering that it's\n> impossible to reproduce the problem with either cat or vim as the\n> EDITOR, you might be inclined to classify this as an Emacs bug. In\n> that case, why can't I reproduce it without submodules?\n\nHow about something like this as a workaround for emacs?\n\n-- 8< --\ndiff --git a/editor.c b/editor.c\nindex 27bdecd..fda3e41 100644\n--- a/editor.c\n+++ b/editor.c\n@@ -37,7 +37,8 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en\n \t\treturn error(\"Terminal is dumb, but EDITOR unset\");\n \n \tif (strcmp(editor, \":\")) {\n-\t\tconst char *args[] = { editor, path, NULL };\n+\t\tchar *rpath = realpath(path, NULL);\n+\t\tconst char *args[] = { editor, rpath, NULL };\n \t\tstruct child_process p;\n \t\tint ret, sig;\n \n@@ -51,6 +52,7 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en\n \t\tsigchain_push(SIGINT, SIG_IGN);\n \t\tsigchain_push(SIGQUIT, SIG_IGN);\n \t\tret = finish_command(&p);\n+\t\tfree(rpath);\n \t\tsig = ret - 128;\n \t\tsigchain_pop(SIGINT);\n \t\tsigchain_pop(SIGQUIT);\n-- 8< --\n\n> \n> I'm going off to eat cake before I tear my hair out in frustration.\n"},{"id":"224198","messageId":"CALkWK0nFDyFqBPatsbQ-0mGXQ-6N5Xs9gKioknuGX9a7UiD4Fg@mail.gmail.com","threadId":"34550","inReplyTo":"CACsJy8AuAy7PnEU20k23gVRQoFrLhJrM6hfESZKshUA578c3Ew@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-28T08:49:10Z","receivedAt":"2013-07-28T08:49:10Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Duy Nguyen wrote:\n> I think instead of letting the kernel walk the path, emacs does it by\n> itself.\n\nIf this were true, shouldn't we be able to reproduce the behavior with\nmy no-submodules symlink testcase?  How can it resolve symlinks in one\ncase, and not in the other case?\n"},{"id":"224200","messageId":"CACsJy8CAfCVtTmgtEaix6RwYm4Sj7Ot_BjuObS+qvQ=QNnQ0OA@mail.gmail.com","threadId":"34550","inReplyTo":"CALkWK0nFDyFqBPatsbQ-0mGXQ-6N5Xs9gKioknuGX9a7UiD4Fg@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-07-28T09:06:23Z","receivedAt":"2013-07-28T09:06:23Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sun, Jul 28, 2013 at 3:49 PM, Ramkumar Ramachandra\n<artagnon@gmail.com> wrote:\n> Duy Nguyen wrote:\n>> I think instead of letting the kernel walk the path, emacs does it by\n>> itself.\n>\n> If this were true, shouldn't we be able to reproduce the behavior with\n> my no-submodules symlink testcase?  How can it resolve symlinks in one\n> case, and not in the other case?\n\nIn the no-submodules symlink test case, the path given to the editor\nis .git/COMMIT_EDITMSG, no following \"..\" back in the symlink target.\nThis bug can be reproduced without git involved:\n\nmkdir z z/a z/b\necho ha >z/a/file\nln -s z/b\ncd b\ncat ../a/file\nemacs ../a/file # fail to open 'file'\n-- \nDuy\n"},{"id":"224201","messageId":"CALkWK0mFj3fy7k=LirZ9LotGAxt7ptSpzZpR0sCg4OPmPb1WjA@mail.gmail.com","threadId":"34550","inReplyTo":"CACsJy8CAfCVtTmgtEaix6RwYm4Sj7Ot_BjuObS+qvQ=QNnQ0OA@mail.gmail.com","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-28T09:16:44Z","receivedAt":"2013-07-28T09:16:44Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Duy Nguyen wrote:\n> In the no-submodules symlink test case, the path given to the editor\n> is .git/COMMIT_EDITMSG, no following \"..\" back in the symlink target.\n\nThanks, and sorry about the stupidity.  I just patched\nbuiltin/commit.c to check this.\n\n> This bug can be reproduced without git involved:\n\nI'm taking this up with Emacs-Devel; you are CC'ed.\n"},{"id":"224202","messageId":"CALkWK0n-a8XB_ZRmQBTxq2DQ79VfPYyuvPBsi=Zrf_ThzUsoyw@mail.gmail.com","threadId":"34550","inReplyTo":"20130728050009.GA10844@lanh","subject":"Re: [BUG] git_path() returns relative paths","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-07-28T09:24:49Z","receivedAt":"2013-07-28T09:24:49Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Duy Nguyen wrote:\n> How about something like this as a workaround for emacs?\n\nEven if we do manage to patch Emacs now, we still need to support\nolder versions: so yeah, this is an urgent candidate for maint.  I'm\nwaiting for the word from Emacs-Devel before writing out a commit\nmessage.\n"}]}