{"thread":{"id":"30437","subject":"Git commit path vs rebase path","startedAt":"2012-05-06T04:24:16Z","lastAt":"2012-05-24T18:27:53Z","messageCount":32,"participants":["Steven Penny","Junio C Hamano","Johannes Sixt","Ramsay Jones"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"190874","messageId":"CAAXzdLU6bQ7ta4_-WfGJVaJgt1R5tX=4PW2sq3SdjAB+F72w+Q@mail.gmail.com","threadId":"30437","inReplyTo":null,"subject":"Git commit path vs rebase path","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2012-05-06T04:24:16Z","receivedAt":"2012-05-06T04:24:16Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"I have noticed\n\ngit commit uses this path\n\n.git/COMMIT_EDITMSG\n\ngit rebase uses this path\n\n/home/Steven/jquery/.git/rebase-merge/git-rebase-todo\n\nSo git commit is using a relative path while git rebase is using absolute path.\n\nThis causes problem in Windows if your editor does not understand linux paths,\ne.g. notepad, Notepad2, Notepad++, etc.\n"},{"id":"191012","messageId":"7vaa1j7vg1.fsf@alter.siamese.dyndns.org","threadId":"30437","inReplyTo":"CAAXzdLU6bQ7ta4_-WfGJVaJgt1R5tX=4PW2sq3SdjAB+F72w+Q@mail.gmail.com","subject":"Re: Git commit path vs rebase path","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-07T17:27:42Z","receivedAt":"2012-05-07T17:27:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steven Penny <svnpenn@gmail.com> writes:\n\n> I have noticed\n>\n> git commit uses this path\n>\n> .git/COMMIT_EDITMSG\n>\n> git rebase uses this path\n>\n> /home/Steven/jquery/.git/rebase-merge/git-rebase-todo\n>\n> So git commit is using a relative path while git rebase is using absolute path.\n>\n> This causes problem in Windows if your editor does not understand linux paths,\n> e.g. notepad, Notepad2, Notepad++, etc.\n\nHrm, this is not limited to rebase, though.  All shell scripted Porcelain\ncommand use git-sh-setup that gives GIT_DIR as the full path, primarily so\nthat the implementation of the Porcelain can safely chdir around without\nhaving to worry about relative paths in GIT_DIR.\n\nMost of the time, the commands that use git-sh-setup do cd_to_toplevel\nvery early.  For these commands, unless you are using GIT_DIR from your\nown environment (i.e. where people set the environment point to a place\ntotally unrelated to the working tree and/or the current directory), it\nmight look nicer if GIT_DIR given were .git/rebase-merge/git-rebase-todo,\nbut that will not be the real solution, as sometimes your editor _must_\ndeal with the full path anyway.  So the issue is _not_ that the path is\nabsolute, it is that the path is given as a wrong kind of absolute path.\n\nWhich suggests that \"$(cd \"$GIT_DIR\" && pwd)\" must give a full path that\nis suitable for the platform, and your platform wants it to be something\nlike \"c:\\home\\steven\\jquery\\...\"?  I do not have any Windows environment\nto further my speculation, so I'll leave the rest to Windows experts who\nmay be lurking on this list.\n\nThe relevant code snippet in git-sh-setup.sh is this part.\n\n# Make sure we are in a valid repository of a vintage we understand,\n# if we require to be in a git repository.\nif test -z \"$NONGIT_OK\"\nthen\n\tGIT_DIR=$(git rev-parse --git-dir) || exit\n\tif [ -z \"$SUBDIRECTORY_OK\" ]\n\tthen\n\t\ttest -z \"$(git rev-parse --show-cdup)\" || {\n\t\t\texit=$?\n\t\t\techo >&2 \"You need to run this command from the toplevel of the working tree.\"\n\t\t\texit $exit\n\t\t}\n\tfi\n\ttest -n \"$GIT_DIR\" && GIT_DIR=$(cd \"$GIT_DIR\" && pwd) || {\n\t\techo >&2 \"Unable to determine absolute path of git directory\"\n\t\texit 1\n\t}\n\t: ${GIT_OBJECT_DIRECTORY=\"$GIT_DIR/objects\"}\nfi\n"},{"id":"191067","messageId":"4FA8BBB0.1080406@viscovery.net","threadId":"30437","inReplyTo":"7vaa1j7vg1.fsf@alter.siamese.dyndns.org","subject":"Re: Git commit path vs rebase path","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2012-05-08T06:22:40Z","receivedAt":"2012-05-08T06:22:40Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 5/7/2012 19:27, schrieb Junio C Hamano:\n> Steven Penny <svnpenn@gmail.com> writes:\n> \n>> I have noticed\n>>\n>> git commit uses this path\n>>\n>> .git/COMMIT_EDITMSG\n>>\n>> git rebase uses this path\n>>\n>> /home/Steven/jquery/.git/rebase-merge/git-rebase-todo\n>>\n>> So git commit is using a relative path while git rebase is using absolute path.\n>>\n>> This causes problem in Windows if your editor does not understand linux paths,\n>> e.g. notepad, Notepad2, Notepad++, etc.\n> \n> ... the issue is _not_ that the path is\n> absolute, it is that the path is given as a wrong kind of absolute path.\n> \n> Which suggests that \"$(cd \"$GIT_DIR\" && pwd)\" must give a full path that\n> is suitable for the platform, and your platform wants it to be something\n> like \"c:\\home\\steven\\jquery\\...\"?\n\nThe problem should be mitigated by be39048a7 (git-sh-setup.sh: Add an\npwd() function for MinGW), where the above now returns a Windows-style\nabsolute path, albeit with forward slashes instead of the backslashes.\n\nI don't know what \"/home/...\" is in Steven's case, because it should look\nmore like \"/c/home/...\" unless it is an MSYS mount point, but even then it\nshould be reported as Windows-style path with the new pwd function.\n\nIOW, the problem should be fixed in the next release.\n\n-- Hannes\n"},{"id":"191068","messageId":"CAAXzdLVaDAQkd_9qjnmTRoy8ccpyrZvwvBJQAfkp7LkYa7Li2A@mail.gmail.com","threadId":"30437","inReplyTo":"4FA8BBB0.1080406@viscovery.net","subject":"Re: Git commit path vs rebase path","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2012-05-08T06:44:47Z","receivedAt":"2012-05-08T06:44:47Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"Johannes Sixt wrote:\n> The problem should be mitigated by be39048a7 (git-sh-setup.sh: Add an\n> pwd() function for MinGW), where the above now returns a Windows-style\n> absolute path, albeit with forward slashes instead of the backslashes.\n\nhttp://github.com/git/git/commit/be390\n\nThis looks like a good solution for MinGW, but cygwin will not support that\n\n$ pwd -W\nbash: pwd: -W: invalid option\npwd: usage: pwd [-LP]\n\nCygwin uses cygpath\n\n$ cygpath -m /c/Windows/System32\nC:/Windows/System32\n"},{"id":"191069","messageId":"4FA8C5DB.5060002@viscovery.net","threadId":"30437","inReplyTo":"CAAXzdLVaDAQkd_9qjnmTRoy8ccpyrZvwvBJQAfkp7LkYa7Li2A@mail.gmail.com","subject":"Re: Git commit path vs rebase path","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2012-05-08T07:06:03Z","receivedAt":"2012-05-08T07:06:03Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 5/8/2012 8:44, schrieb Steven Penny:\n> Johannes Sixt wrote:\n>> The problem should be mitigated by be39048a7 (git-sh-setup.sh: Add an\n>> pwd() function for MinGW), where the above now returns a Windows-style\n>> absolute path, albeit with forward slashes instead of the backslashes.\n> \n> http://github.com/git/git/commit/be390\n> \n> This looks like a good solution for MinGW, but cygwin will not support that\n> \n> $ pwd -W\n> bash: pwd: -W: invalid option\n> pwd: usage: pwd [-LP]\n\nAre you saying that the new pwd function will also be used on Cygwin? That\nwould be a bug.\n\n-- Hannes\n"},{"id":"191070","messageId":"CAAXzdLW9_O+feVpBhDSXQH_SFRdrct1tjadpFoJ5d7-Qd1LWEg@mail.gmail.com","threadId":"30437","inReplyTo":"4FA8C5DB.5060002@viscovery.net","subject":"Re: Git commit path vs rebase path","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2012-05-08T07:11:07Z","receivedAt":"2012-05-08T07:11:07Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"Johannes Sixt wrote:\n> Are you saying that the new pwd function will also be used on Cygwin? That\n> would be a bug.\n\nThe linked patch should fix the problem for _MinGW_ users.\n\nThe problem will persist with _Cygwin_ users.\n"},{"id":"191121","messageId":"7vhavqwqpz.fsf@alter.siamese.dyndns.org","threadId":"30437","inReplyTo":"CAAXzdLW9_O+feVpBhDSXQH_SFRdrct1tjadpFoJ5d7-Qd1LWEg@mail.gmail.com","subject":"Re: Git commit path vs rebase path","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-08T17:02:48Z","receivedAt":"2012-05-08T17:02:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steven Penny <svnpenn@gmail.com> writes:\n\n> Johannes Sixt wrote:\n>> Are you saying that the new pwd function will also be used on Cygwin? That\n>> would be a bug.\n>\n> The linked patch should fix the problem for _MinGW_ users.\n>\n> The problem will persist with _Cygwin_ users.\n\nWhat does a full pathname, fed as a parameter when invoking Windows native\nbinaries like notepad, look like in a Cygwin environment?  That is, if you\nare writing a bash script that is meant to run in a Cygwin environment,\nand if the script takes the name of a file in the current directory, but\nit needs to chdir around for its own reasons before spawning notepad on\nthe file, i.e.\n\n\t#!/bin/bash\n\tfile=\"$(pwd)/$1\"\n        ...\n        cd ..some..where..else..you..have..no..control..over\n        notepad \"$file\"\n\nwhat is the right incantation to replace `pwd` in 'file=\"$(pwd)/$1\"'\nabove?\n\nWhatever that is, using that instead of `pwd` in git-sh-setup.sh here:\n\n\ttest -n \"$GIT_DIR\" && GIT_DIR=$(cd \"$GIT_DIR\" && pwd) || {\n\nwould be the solution.\n"},{"id":"191125","messageId":"7v1umuwpo9.fsf@alter.siamese.dyndns.org","threadId":"30437","inReplyTo":"7vhavqwqpz.fsf@alter.siamese.dyndns.org","subject":"Re: Git commit path vs rebase path","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-08T17:25:26Z","receivedAt":"2012-05-08T17:25:26Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Steven Penny <svnpenn@gmail.com> writes:\n>\n>> Johannes Sixt wrote:\n>>> Are you saying that the new pwd function will also be used on Cygwin? That\n>>> would be a bug.\n>>\n>> The linked patch should fix the problem for _MinGW_ users.\n>>\n>> The problem will persist with _Cygwin_ users.\n>\n> What does a full pathname, fed as a parameter when invoking Windows native\n> binaries like notepad, look like in a Cygwin environment?  That is, if you\n> are writing a bash script that is meant to run in a Cygwin environment,\n> and if the script takes the name of a file in the current directory, but\n> it needs to chdir around for its own reasons before spawning notepad on\n> the file, i.e.\n>\n> \t#!/bin/bash\n> \tfile=\"$(pwd)/$1\"\n>         ...\n>         cd ..some..where..else..you..have..no..control..over\n>         notepad \"$file\"\n>\n> what is the right incantation to replace `pwd` in 'file=\"$(pwd)/$1\"'\n> above?\n>\n> Whatever that is, using that instead of `pwd` in git-sh-setup.sh here:\n>\n> \ttest -n \"$GIT_DIR\" && GIT_DIR=$(cd \"$GIT_DIR\" && pwd) || {\n>\n> would be the solution.\n\nActually, the above is stated rather poorly.  The path that ends up in\n$file must be usable by both Windows native and Cygwin programs, as the\nuser may be using \"vi\" from Cygwin, or \"notepad\" like your example.\n\nIf there is no way to formulate $file to be acceptable for both, I do not\nsee any sane solution other than one side compromising for the rest,\nperhaps by having\n\n\t$ cat >notepad.sh <<\\EOF\n        file=$(cygpath -m \"$1\") && exec notepad.exe \"$file\"\n        EOF\n\non the end-user side, or something like that.\n"},{"id":"191156","messageId":"CAAXzdLVj0szCgpdOSdhnLdkBKAM+e6vrQpvrsz4HeUo+Nh1K6A@mail.gmail.com","threadId":"30437","inReplyTo":"7v1umuwpo9.fsf@alter.siamese.dyndns.org","subject":"Re: Git commit path vs rebase path","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2012-05-08T22:47:45Z","receivedAt":"2012-05-08T22:47:45Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"Junio C Hamano wrote:\n> Actually, the above is stated rather poorly.  The path that ends up in\n> $file must be usable by both Windows native and Cygwin programs, as the\n> user may be using \"vi\" from Cygwin, or \"notepad\" like your example.\n\nExcellent point.\n\nI ran some test and this is what I came up with\n\n# VI\n/cygdrive/c/test/hello.sh # works\nC:\\test\\hello.sh # works\nC:/test/hello/sh # works\n\n# NOTEPAD\n/cygdrive/c/test/hello.sh # does not work\nC:\\test\\hello.sh # works\nC:/test/hello.sh # works\n\nso the best compromise would be \"C:/test/hello.sh\" which can be created with\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 7b3ae75..ba198d2 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -260,6 +260,11 @@ case $(uname -s) in\n \t\treturn 1\n \t}\n \t;;\n+*CYGWIN*)\n+    pwd () {\n+        builtin cygpath -m\n+    }\n+    ;;\n *)\n \tis_absolute_path () {\n \t\tcase \"$1\" in\n\nhttp://github.com/svnpenn/git/commit/692bc\n"},{"id":"191244","messageId":"7v62c5qaun.fsf@alter.siamese.dyndns.org","threadId":"30437","inReplyTo":"CAAXzdLVj0szCgpdOSdhnLdkBKAM+e6vrQpvrsz4HeUo+Nh1K6A@mail.gmail.com","subject":"Re: Git commit path vs rebase path","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-09T21:54:24Z","receivedAt":"2012-05-09T21:54:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steven Penny <svnpenn@gmail.com> writes:\n\n> so the best compromise would be \"C:/test/hello.sh\" which can be created with\n>\n> diff --git a/git-sh-setup.sh b/git-sh-setup.sh\n> index 7b3ae75..ba198d2 100644\n> --- a/git-sh-setup.sh\n> +++ b/git-sh-setup.sh\n> @@ -260,6 +260,11 @@ case $(uname -s) in\n>  \t\treturn 1\n>  \t}\n>  \t;;\n> +*CYGWIN*)\n> +    pwd () {\n> +        builtin cygpath -m\n> +    }\n> +    ;;\n\nWhat does \"uname -s\" say on cygwin exactly?  Our existing system detection\ncode I found was in the Makefile and it looks out \"uname -o\" output and\ncompares it with \"Cygwin\".\n\nI am not suggesting to change this part of the code to use \"uname -o\" at\nall; I just want to double check that the above *CYGWIN* matches it.\n"},{"id":"191253","messageId":"CAAXzdLUoExTJyDWBJBdWNzTRRN78Bj+gEs9c107B9Nne0Pxa1A@mail.gmail.com","threadId":"30437","inReplyTo":"7v62c5qaun.fsf@alter.siamese.dyndns.org","subject":"Re: Git commit path vs rebase path","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2012-05-09T23:14:00Z","receivedAt":"2012-05-09T23:14:00Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"Junio C Hamano wrote:\n> What does \"uname -s\" say on cygwin exactly?  Our existing system detection\n> code I found was in the Makefile and it looks out \"uname -o\" output and\n> compares it with \"Cygwin\".\n\nThis is what I get\n\n$ uname -s\nCYGWIN_NT-6.1-WOW64\n\n$ uname -o\nCygwin\n"},{"id":"191333","messageId":"4FAC047A.4010001@ramsay1.demon.co.uk","threadId":"30437","inReplyTo":"CAAXzdLVj0szCgpdOSdhnLdkBKAM+e6vrQpvrsz4HeUo+Nh1K6A@mail.gmail.com","subject":"Re: Git commit path vs rebase path","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-05-10T18:10:02Z","receivedAt":"2012-05-10T18:10:02Z","isPatch":false,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Steven Penny wrote:\n> Junio C Hamano wrote:\n>> Actually, the above is stated rather poorly.  The path that ends up in\n>> $file must be usable by both Windows native and Cygwin programs, as the\n>> user may be using \"vi\" from Cygwin, or \"notepad\" like your example.\n> \n> Excellent point.\n> \n> I ran some test and this is what I came up with\n> \n> # VI\n> /cygdrive/c/test/hello.sh # works\n> C:\\test\\hello.sh # works\n> C:/test/hello/sh # works\n> \n> # NOTEPAD\n> /cygdrive/c/test/hello.sh # does not work\n> C:\\test\\hello.sh # works\n> C:/test/hello.sh # works\n> \n> so the best compromise would be \"C:/test/hello.sh\" which can be created with\n> \n> diff --git a/git-sh-setup.sh b/git-sh-setup.sh\n> index 7b3ae75..ba198d2 100644\n> --- a/git-sh-setup.sh\n> +++ b/git-sh-setup.sh\n> @@ -260,6 +260,11 @@ case $(uname -s) in\n>  \t\treturn 1\n>  \t}\n>  \t;;\n> +*CYGWIN*)\n> +    pwd () {\n> +        builtin cygpath -m\n> +    }\n> +    ;;\n>  *)\n>  \tis_absolute_path () {\n>  \t\tcase \"$1\" in\n> \n> http://github.com/svnpenn/git/commit/692bc\n\nI would rather define a script; it can then be used independently of git.\n\nPersonally, I don't have this specific problem because I use (the cygwin\nversion of) vim. (does anybody actually use notepad?)\n\nI mostly, but not exclusively, use cygwin tools on cygwin. For example I\nuse win32 versions of doxygen, ghostscript, tex (MikTex 2.7), graphviz etc.\nHowever, the makefiles which drive those tools use relative paths ...\n\nIn fact the only problem I have encountered is with firefox, which I\nresolved by hacking up a script. Indeed I have already posted to the\nlist on this issue before (back in January 2009) and, to save you the\neffort of trawling the archives, I append that mail below.\n\nHTH\n\nATB,\nRamsay Jones\n\n-- >8 --\nDate: Sat, 24 Jan 2009 18:51:23 +0000\nFrom: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\nTo: =?ISO-8859-1?Q?Bj=F6rn_Steinbrink?= <B.Steinbrink@gmx.de>\nCC: Junio C Hamano <gitster@pobox.com>,  jaeckel@stzedn.de, \n git@vger.kernel.org\nSubject: Re: [PATCH] cygwin: Convert paths for html help from posix to windows\n\nBjörn Steinbrink wrote:\n> When using \"git help --web\" with cygwin, we used to pass the posix path\n> to the browser, but a native windows browser will expect a windows path\n> and is unable to make use of the given path.\n> \n> So the cygwin port gets its own open_html implementation that handles\n> the path conversion.\n> \n> Reported-by: Steffen Jaeckel <jaeckel@stzedn.de>\n> Tested-by: Steffen Jaeckel <jaeckel@stzedn.de>\n> \n> Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>\n> ---\n> OK, I don't really know if this is the right way to do it. Maybe when\n> the browser was built for cygwin this breaks? I have no clue, it's\n> admittedly just the result of a quick glance at the code and some\n> googling to find the \"right\" cygwin function... :-/\n> \n\nHi Björn,\n\nI had the same problem. However, rather than modifying git, I created a\nfirefox wrapper script (in ~/bin) which used the cygpath command line\ntool to do the path conversion. Also, if you use \"git instaweb\", you\nalso need to filter out http URLs and pass them through un-molested\nby cygpath (it turns http://localhost into http:\\localhost).\n\nMy script is clearly a \"quick hack\" just to get something working for\nme, but you may find it useful as a starting point for your own\n(\"proper\" ;-) script, so I've included it below.\n\nHTH,\nRamsay Jones\n\n-->8--\n#!/bin/sh\n#\n\nwhile test $# != 0\ndo\n    case \"$1\" in\n\t-version)\n\t    echo \"firefox 1.5.0.2\"\n\t    exit 0\n\t    ;;\n\t-new-tab)\n\t    echo \"-new-tab not supported\"\n\t    exit 1\n\t    ;;\n\t--)\n\t    shift\n\t    break\n\t    ;;\n\t-*)\n\t    echo \"option '$1' not supported\"\n\t    exit 1\n\t    ;;\n\t*)\n\t    break\n\t    ;;\n    esac\n    shift\ndone\n\nif test \"$1\" = \"\"\nthen\n\tp=\nelse\n\tcase \"$1\" in\n\t    http*)\n\t\tp=\"$1\"\n\t\t;;\n\t    *)\n\t\tp=\"$(cygpath -w \"$1\")\"\n\t\t;;\n\tesac\nfi\n\n\n\"/cygdrive/c/Program Files/Mozilla Firefox/firefox.exe\" \"$p\"\n\nexit 0\n\n\n\n-- 8< --\n"},{"id":"191377","messageId":"CAAXzdLXbYp5YW9cZXxmRJk0MP=6PU897f4nuTe4ipLqk+EH9PQ@mail.gmail.com","threadId":"30437","inReplyTo":"4FAC047A.4010001@ramsay1.demon.co.uk","subject":"Re: Git commit path vs rebase path","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2012-05-11T04:35:48Z","receivedAt":"2012-05-11T04:35:48Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"Ramsay Jones wrote:\n> I would rather define a script; it can then be used independently of git.\n\nSo your suggestion is to have git-sh-setup.sh account for MinGW, which is its\ncurrent state, but not account for Cygwin?\n\n> Personally, I don't have this specific problem because I use (the cygwin\n> version of) vim. (does anybody actually use notepad?)\n\nIf you had read carefully, you would have noticed that I mentioned more than\nnotepad. As well Notepad2, and Notepad++, etc.\n\n\n> I mostly, but not exclusively, use cygwin tools on cygwin. For example I\n> use win32 versions of doxygen, ghostscript, tex (MikTex 2.7), graphviz etc.\n> However, the makefiles which drive those tools use relative paths ...\n\nThis convo is not about what tools _you_ use, but about the current\nincompatibility with several native windows text editors.\n"},{"id":"191477","messageId":"4FB03CA1.4030703@ramsay1.demon.co.uk","threadId":"30437","inReplyTo":"CAAXzdLXbYp5YW9cZXxmRJk0MP=6PU897f4nuTe4ipLqk+EH9PQ@mail.gmail.com","subject":"Re: Git commit path vs rebase path","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-05-13T22:58:41Z","receivedAt":"2012-05-13T22:58:41Z","isPatch":false,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Steven Penny wrote:\n> Ramsay Jones wrote:\n>> I would rather define a script; it can then be used independently of git.\n> \n> So your suggestion is to have git-sh-setup.sh account for MinGW, which is its\n> current state, but not account for Cygwin?\n\nI wasn't specifically suggesting that no; I was suggesting that I prefer to\nfix the problem with a script on cygwin. (Again, the script can be used\nindependently of git)\n\nBTW, Johannes, earlier you said commit be39048 (\"git-sh-setup.sh: Add an pwd()\nfunction for MinGW\", 17-04-2012) would fix the problem on MinGW; I'm not so\nsure it will. I haven't actually tested it, so don't take my word for it. ;-P\n(See below for an explanation of my doubts)\n\n>> Personally, I don't have this specific problem because I use (the cygwin\n>> version of) vim. (does anybody actually use notepad?)\n> \n> If you had read carefully, you would have noticed that I mentioned more than\n> notepad. As well Notepad2, and Notepad++, etc.\n\nYes, I did notice that you mentioned more than notepad ...\n\n>> I mostly, but not exclusively, use cygwin tools on cygwin. For example I\n>> use win32 versions of doxygen, ghostscript, tex (MikTex 2.7), graphviz etc.\n>> However, the makefiles which drive those tools use relative paths ...\n> \n> This convo is not about what tools _you_ use, but about the current\n> incompatibility with several native windows text editors.\n\nOK.\n\nSo, yes, I didn't give your patch a look; sorry about that. Let's take a look\nnow (quoting from earlier email):\n\n> diff --git a/git-sh-setup.sh b/git-sh-setup.sh\n> > index 7b3ae75..ba198d2 100644\n> > --- a/git-sh-setup.sh\n> > +++ b/git-sh-setup.sh\n> > @@ -260,6 +260,11 @@ case $(uname -s) in\n> >  \t\treturn 1\n> >  \t}\n> >  \t;;\n> > +*CYGWIN*)\n> > +    pwd () {\n> > +        builtin cygpath -m\n> > +    }\n> > +    ;;\n> >  *)\n> >  \tis_absolute_path () {\n> >  \t\tcase \"$1\" in\n> > \n> > http://github.com/svnpenn/git/commit/692bc\n\nI haven't actually tried to apply or test your patch, so take the\nfollowing with a pinch of salt ...\n\nI don't think this will work because:\n\n    - cygpath is not a bash builtin, so bash *should* simply issue\n      an error something along the lines of \"not a shell builtin\".\n\n    - cygpath requires an input path\n\nSo, I would have expected the body of the pwd function to be something like:\n\n    cygpath -m \"$PWD\"\n\nor maybe\n\n    cygpath -m \"$(builtin pwd)\"\n\n(Again, I'm just typing into my mail client, so not tested ...)\n\nAlso note that the MinGW pwd() uses a shell builtin and so, unlike the above,\ndoes not suffer any fork+exec overhead.\n\nIf we fix the above, then another problem (*which MinGW shares*) is that the\npwd() function is defined *after* the code that sets $GIT_DIR from which the\nrebase state directory name is derived (see git-sh-setup.sh lines 223-239).\n\nNote that cygwin git will create the various inputs (commit template say) with\nlf only line endings; so the windows text editor you use must be able to cope\nwith such an input. (I think the PSEdit editor will cope just fine).\n\nSimilar comments apply to all other external programs launched by git (for\nexample, external diff/merge tools, clean/smudge filters ...).\n\nHTH\n\nATB,\nRamsay Jones\n"},{"id":"191479","messageId":"CAAXzdLWTg8MQ7h6uvto3SxHwxsC63_1mj9WhnXm+ATvPxVf5Fg@mail.gmail.com","threadId":"30437","inReplyTo":"4FB03CA1.4030703@ramsay1.demon.co.uk","subject":"Re: Git commit path vs rebase path","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2012-05-13T23:42:38Z","receivedAt":"2012-05-13T23:42:38Z","isPatch":false,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"Ramsay Jones wrote:\n> I haven't actually tried to apply or test your patch, so take the\n> following with a pinch of salt ...\n>\n> I don't think this will work because:\n>\n>    - cygpath is not a bash builtin, so bash *should* simply issue\n>      an error something along the lines of \"not a shell builtin\".\n>\n>    - cygpath requires an input path\n>\n> So, I would have expected the body of the pwd function to be something like:\n>\n>    cygpath -m \"$PWD\"\n\nIf you would actually look at the file, you would see that pretty much\neverything you just wrote is wrong\n\nSNIPPET\n\n*MINGW*)\n\tpwd () {\n\t\tbuiltin pwd -W\n\t}\n\nhttp://github.com/git/git/blob/master/git-sh-setup.sh\n"},{"id":"191481","messageId":"4FB09FF2.70309@viscovery.net","threadId":"30437","inReplyTo":"4FB03CA1.4030703@ramsay1.demon.co.uk","subject":"Re: Git commit path vs rebase path","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2012-05-14T06:02:26Z","receivedAt":"2012-05-14T06:02:26Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 5/14/2012 0:58, schrieb Ramsay Jones:\n> BTW, Johannes, earlier you said commit be39048 (\"git-sh-setup.sh: Add an pwd()\n> function for MinGW\", 17-04-2012) would fix the problem on MinGW; I'm not so\n> sure it will. \n\n> [...] problem (*which MinGW shares*) is that the\n> pwd() function is defined *after* the code that sets $GIT_DIR from which the\n> rebase state directory name is derived (see git-sh-setup.sh lines 223-239).\n\nGood catch!\n\nNevertheless, if I set GIT_EDITOR to \"notepad\", 'git rebase -i' works to\nsome degree. Leaving aside that it does not understand LF line endings, it\nopens the git-rebase-todo file; I can edit and save it. That is, it looks\nlike a usable Windows style path was passed to Notepad. (This is with\nMinGW git, of course.)\n\nBut I can't use \"Save As\": Notepad just responds with \"Error #3002\". I\nwould attribute this to the forward slashes in the absolute path name, and\nthat the file dialog can't cope with them. Personally, I don't think this\nis a big deal: We have heard of people who set GIT_EDITOR to something\nWindows-y, but there were no complaints of the kind I mention in this\nparagraph. (Why should there be any? There is no reason to use \"Save As\"\nwhen git invokes an editor.)\n\n-- Hannes\n"},{"id":"191559","messageId":"4FB2931A.1080504@ramsay1.demon.co.uk","threadId":"30437","inReplyTo":"4FB09FF2.70309@viscovery.net","subject":"Re: Git commit path vs rebase path","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-05-15T17:32:10Z","receivedAt":"2012-05-15T17:32:10Z","isPatch":false,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Johannes Sixt wrote:\n> Am 5/14/2012 0:58, schrieb Ramsay Jones:\n>> BTW, Johannes, earlier you said commit be39048 (\"git-sh-setup.sh: Add an pwd()\n>> function for MinGW\", 17-04-2012) would fix the problem on MinGW; I'm not so\n>> sure it will. \n> \n>> [...] problem (*which MinGW shares*) is that the\n>> pwd() function is defined *after* the code that sets $GIT_DIR from which the\n>> rebase state directory name is derived (see git-sh-setup.sh lines 223-239).\n> \n> Good catch!\n> \n> Nevertheless, if I set GIT_EDITOR to \"notepad\", 'git rebase -i' works to\n> some degree. Leaving aside that it does not understand LF line endings, it\n> opens the git-rebase-todo file; I can edit and save it. That is, it looks\n> like a usable Windows style path was passed to Notepad. (This is with\n> MinGW git, of course.)\n> \n\nI was about to, confidently, proclaim that it should fail when\nyou run that rebase from a subdirectory ... Unfortunately, it\nseems to work! *ahem*\n\nThe reason I was confident, is simply that I have seen this\npattern:\n\n    p= ...some path...\n    p=$(cd \"$p\" && pwd)\n\nmany times while debugging scripts on MinGW, so I 'know' that if\np is initially a relative path, then the result is an absolute\nwindows path. For example, while cwd is /home/ramsay/git then:\n\n    .git => C:/msysgit/msysgit/home/ramsay/git/.git\n\nWhereas if p is initially an absolute windows path, then the result\nis a POSIX-like path, viz:\n\n    C:/msysgit/msysgit/home/ramsay/git/.git => /usr/home/ramsay/git/.git\n\nIf you combine that with the behaviour of 'git rev-parse', thus:\n\n    $ cd /home/ramsay/git\n    $ git rev-parse --git-dir\n    .git\n    $ cd xdiff\n    $ git rev-parse --git-dir\n    C:/msysgit/msysgit/home/ramsay/git/.git\n    $\n\nyou should see \"git rebase -i\" invoking the editor with a POSIX\npath.\n\n[BTW, I have noticed that I sometimes get different behaviour when\nI type this stuff into an interactive shell. :(]\n\nAnyway, a bit of debugging shows that I was right, kinda! :-D\n\nI placed a \"set -x\" in git-sh-setup (line 222) just before the code\nto set up GIT_DIR and ran git-rebase like so:\n\n    $ cd /home/ramsay/git\n    $ GIT_EDITOR=false ./bin-wrappers/git rebase -i master uname >ttt 2>&1\n    $ cd xdiff\n    $ GIT_EDITOR=false ../bin-wrappers/git rebase -i master uname >sss 2>&1\n    $ diff ../ttt sss | more\n\nwhich showed that in the subdirectory case, git was indeed invoking\nthe editor with a POSIX-like path. (The output files, ttt and sss, show\nsome other interesting/odd behaviour).\n\n['uname' is an old branch of mine that, currently, is based on v1.7.10]\n\nThe reason it works, despite the above, is clear if you now run:\n\n    $ GIT_EDITOR=args ../bin-wrappers/git rebase -i master uname\n\n    ...\n\n    +++ git var GIT_EDITOR\n    ++ GIT_SEQUENCE_EDITOR=args\n    ++ eval args '\"$@\"'\n    +++ args /usr/home/ramsay/git/.git/rebase-merge/git-rebase-todo\n    argv[0] = 'C:\\msysgit\\msysgit\\home\\ramsay\\bin\\args.exe'\n    argv[1] = 'C:/msysgit/msysgit/home/ramsay/git/.git/rebase-merge/git-rebase-todo'\n\n    ++ die_abort 'Could not execute editor'\n    ++ rm -rf /usr/home/ramsay/git/.git/rebase-merge\n    ++ die 'Could not execute editor'\n    ++ die_with_status 1 'Could not execute editor'\n    ++ status=1\n    ++ shift\n    ++ echo 'Could not execute editor'\n    Could not execute editor\n    ++ exit 1\n\n[I'm sure you can guess what the args program looks like!]\n\nSo, the msys \"path munging\" of program arguments saves the day!\n\nHTH\n\nATB,\nRamsay Jones\n"},{"id":"191575","messageId":"4FB340A9.60607@viscovery.net","threadId":"30437","inReplyTo":"4FB2931A.1080504@ramsay1.demon.co.uk","subject":"Re: Git commit path vs rebase path","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2012-05-16T05:52:41Z","receivedAt":"2012-05-16T05:52:41Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 5/15/2012 19:32, schrieb Ramsay Jones:\n>     ++ GIT_SEQUENCE_EDITOR=args\n>     ++ eval args '\"$@\"'\n>     +++ args /usr/home/ramsay/git/.git/rebase-merge/git-rebase-todo\n>     argv[0] = 'C:\\msysgit\\msysgit\\home\\ramsay\\bin\\args.exe'\n>     argv[1] = 'C:/msysgit/msysgit/home/ramsay/git/.git/rebase-merge/git-rebase-todo'\n...\n> So, the msys \"path munging\" of program arguments saves the day!\n\nAbsolutely. This path munging is an essential detail in the process.\n\nI don't know whether Cygwin has a similar feature, but I suppose not,\notherwise we wouldn't have received this issue report.\n\n-- Hannes\n"},{"id":"191596","messageId":"1337191208-21110-1-git-send-email-gitster@pobox.com","threadId":"30437","inReplyTo":"4FB09FF2.70309@viscovery.net","subject":"[PATCH 0/2] Re: Git commit path vs rebase path","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-16T18:00:06Z","receivedAt":"2012-05-16T18:00:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I do not want to see a discussion hanging around waiting for somebody to\nbring it to conclusion, especially when the topic is not something I can\ngive a tested definitive solution.  It is a sure way to lose the effort so\nfar that brought us almost there but not quite by not following through\nand forgetting about it.\n\nHere are two patches I *think* represent the conclusion of the discussion,\nbut it needs eyeballing from stakeholders.  I may have misunderstood the\nissue entirely.\n\nAlso Steven's patch needs a sign-off.\n\n\nJunio C Hamano (1):\n  git-sh-setup: define workaround wrappers before they are used\n\nSteven Penny (1):\n  git-sh-setup: work around Cygwin path handling gotchas\n\n git-sh-setup.sh | 46 ++++++++++++++++++++++++++--------------------\n 1 file changed, 26 insertions(+), 20 deletions(-)\n\n-- \n1.7.10.2.537.g0ac6509\n"},{"id":"191597","messageId":"1337191208-21110-2-git-send-email-gitster@pobox.com","threadId":"30437","inReplyTo":"1337191208-21110-1-git-send-email-gitster@pobox.com","subject":"[PATCH 1/2] git-sh-setup: define workaround wrappers before they are used","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-16T18:00:07Z","receivedAt":"2012-05-16T18:00:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Recently we tweaked this scriptlet to let mingw port redefine \"pwd\" to\nalways return Windows-style path, but the code to do so came after the\nfirst use of \"pwd\" to set up $GIT_DIR shell variable.\n\nMove the block to define these workaround wrappers, so that everything\neverything that executes when the scriptlet is dot-sourced uses the\nreplacements.\n\nNoticed-by: Ramsay Jones\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n git-sh-setup.sh | 41 +++++++++++++++++++++--------------------\n 1 file changed, 21 insertions(+), 20 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 7b3ae75..770a86e 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -218,27 +218,8 @@ clear_local_git_env() {\n \tunset $(git rev-parse --local-env-vars)\n }\n \n-# Make sure we are in a valid repository of a vintage we understand,\n-# if we require to be in a git repository.\n-if test -z \"$NONGIT_OK\"\n-then\n-\tGIT_DIR=$(git rev-parse --git-dir) || exit\n-\tif [ -z \"$SUBDIRECTORY_OK\" ]\n-\tthen\n-\t\ttest -z \"$(git rev-parse --show-cdup)\" || {\n-\t\t\texit=$?\n-\t\t\techo >&2 \"You need to run this command from the toplevel of the working tree.\"\n-\t\t\texit $exit\n-\t\t}\n-\tfi\n-\ttest -n \"$GIT_DIR\" && GIT_DIR=$(cd \"$GIT_DIR\" && pwd) || {\n-\t\techo >&2 \"Unable to determine absolute path of git directory\"\n-\t\texit 1\n-\t}\n-\t: ${GIT_OBJECT_DIRECTORY=\"$GIT_DIR/objects\"}\n-fi\n \n-# Fix some commands on Windows\n+# Platform specific tweaks to work around some commands\n case $(uname -s) in\n *MINGW*)\n \t# Windows has its own (incompatible) sort and find\n@@ -269,3 +250,23 @@ case $(uname -s) in\n \t\treturn 1\n \t}\n esac\n+\n+# Make sure we are in a valid repository of a vintage we understand,\n+# if we require to be in a git repository.\n+if test -z \"$NONGIT_OK\"\n+then\n+\tGIT_DIR=$(git rev-parse --git-dir) || exit\n+\tif [ -z \"$SUBDIRECTORY_OK\" ]\n+\tthen\n+\t\ttest -z \"$(git rev-parse --show-cdup)\" || {\n+\t\t\texit=$?\n+\t\t\techo >&2 \"You need to run this command from the toplevel of the working tree.\"\n+\t\t\texit $exit\n+\t\t}\n+\tfi\n+\ttest -n \"$GIT_DIR\" && GIT_DIR=$(cd \"$GIT_DIR\" && pwd) || {\n+\t\techo >&2 \"Unable to determine absolute path of git directory\"\n+\t\texit 1\n+\t}\n+\t: ${GIT_OBJECT_DIRECTORY=\"$GIT_DIR/objects\"}\n+fi\n-- \n1.7.10.2.537.g0ac6509\n"},{"id":"191598","messageId":"1337191208-21110-3-git-send-email-gitster@pobox.com","threadId":"30437","inReplyTo":"1337191208-21110-1-git-send-email-gitster@pobox.com","subject":"[PATCH 2/2] git-sh-setup: work around Cygwin path handling gotchas","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-16T18:00:08Z","receivedAt":"2012-05-16T18:00:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"From: Steven Penny <svnpenn@gmail.com>\n\nFrom: Steven Penny <svnpenn@gmail.com>\n\nOn Cygwin, tools built for Cygwin can take both Windows-style paths\n(e.g. C:/dir/file.txt or C:\\dir\\file.txt) and Cygwin-style paths\n(e.g. /cygdrive/c/dir/file.txt), but Windows-native tools can only take\nWindows-style paths.  Because the paths that are relative to $GIT_DIR,\ne.g. the name of the insn sheet file of the \"rebase -i\" command, are given\nto the programs with $GIT_DIR prefixed, and $GIT_DIR in turn is computed\nby calling \"pwd\", wrap \"pwd\" to call \"cygpath -m\" to give a Windows-style\npath, in a way similar to how mingw does this.\n---\n git-sh-setup.sh | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 770a86e..f0f941d 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -241,6 +241,11 @@ case $(uname -s) in\n \t\treturn 1\n \t}\n \t;;\n+*CYGWIN*)\n+\tpwd () {\n+\t\tbuiltin cygpath -m\n+\t}\n+\t;;\n *)\n \tis_absolute_path () {\n \t\tcase \"$1\" in\n-- \n1.7.10.2.537.g0ac6509\n"},{"id":"191600","messageId":"CAAXzdLW5VYnHc41WZ0id=4Qe17dHSj4+J9tqVvG-PvtpXLmh+Q@mail.gmail.com","threadId":"30437","inReplyTo":"1337191208-21110-3-git-send-email-gitster@pobox.com","subject":"Re: [PATCH 2/2] git-sh-setup: work around Cygwin path handling gotchas","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2012-05-16T18:51:27Z","receivedAt":"2012-05-16T18:51:27Z","isPatch":true,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"Junio C Hamano wrote:\n> +*CYGWIN*)\n> +       pwd () {\n> +               builtin cygpath -m\n> +       }\n> +       ;;\n\nOk I got it!\n\nThe problem is twofold\n\n1. Ramsay Jones\twas right, it needs to be called like\n\n\tcygpath -m \"$PWD\"\n\n2. The Cygwin \"pwd\" (and quite possibly MinGW \"pwd\") needs to be defined\n   **before** it is called\n\ndiff -u a/git-sh-setup.sh b/git-sh-setup.sh\n--- a/git-sh-setup.sh\t2012-05-16 13:48:43.160399300 -0500\n+++ b/git-sh-setup.sh\t2012-05-16 13:50:29.465479600 -0500\n@@ -218,26 +218,6 @@\n \tunset $(git rev-parse --local-env-vars)\n }\n\n-# Make sure we are in a valid repository of a vintage we understand,\n-# if we require to be in a git repository.\n-if test -z \"$NONGIT_OK\"\n-then\n-\tGIT_DIR=$(git rev-parse --git-dir) || exit\n-\tif [ -z \"$SUBDIRECTORY_OK\" ]\n-\tthen\n-\t\ttest -z \"$(git rev-parse --show-cdup)\" || {\n-\t\t\texit=$?\n-\t\t\techo >&2 \"You need to run this command from the toplevel of the\nworking tree.\"\n-\t\t\texit $exit\n-\t\t}\n-\tfi\n-\ttest -n \"$GIT_DIR\" && GIT_DIR=$(cd \"$GIT_DIR\" && pwd) || {\n-\t\techo >&2 \"Unable to determine absolute path of git directory\"\n-\t\texit 1\n-\t}\n-\t: ${GIT_OBJECT_DIRECTORY=\"$GIT_DIR/objects\"}\n-fi\n-\n # Fix some commands on Windows\n case $(uname -s) in\n *MINGW*)\n@@ -260,6 +240,11 @@\n \t\treturn 1\n \t}\n \t;;\n+*CYGWIN*)\n+\tpwd () {\n+\t\tcygpath -m \"$PWD\"\n+\t}\n+\t;;\n *)\n \tis_absolute_path () {\n \t\tcase \"$1\" in\n@@ -269,3 +254,23 @@\n \t\treturn 1\n \t}\n esac\n+\n+# Make sure we are in a valid repository of a vintage we understand,\n+# if we require to be in a git repository.\n+if test -z \"$NONGIT_OK\"\n+then\n+\tGIT_DIR=$(git rev-parse --git-dir) || exit\n+\tif [ -z \"$SUBDIRECTORY_OK\" ]\n+\tthen\n+\t\ttest -z \"$(git rev-parse --show-cdup)\" || {\n+\t\t\texit=$?\n+\t\t\techo >&2 \"You need to run this command from the toplevel of the\nworking tree.\"\n+\t\t\texit $exit\n+\t\t}\n+\tfi\n+\ttest -n \"$GIT_DIR\" && GIT_DIR=$(cd \"$GIT_DIR\" && pwd) || {\n+\t\techo >&2 \"Unable to determine absolute path of git directory\"\n+\t\texit 1\n+\t}\n+\t: ${GIT_OBJECT_DIRECTORY=\"$GIT_DIR/objects\"}\n+fi\n"},{"id":"191601","messageId":"7vd364c5kt.fsf@alter.siamese.dyndns.org","threadId":"30437","inReplyTo":"CAAXzdLW5VYnHc41WZ0id=4Qe17dHSj4+J9tqVvG-PvtpXLmh+Q@mail.gmail.com","subject":"Re: [PATCH 2/2] git-sh-setup: work around Cygwin path handling gotchas","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-16T19:02:26Z","receivedAt":"2012-05-16T19:02:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steven Penny <svnpenn@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>> +*CYGWIN*)\n>> +       pwd () {\n>> +               builtin cygpath -m\n>> +       }\n>> +       ;;\n>\n> Ok I got it!\n>\n> The problem is twofold\n>\n> 1. Ramsay Jones\twas right, it needs to be called like\n>\n> \tcygpath -m \"$PWD\"\n>\n> 2. The Cygwin \"pwd\" (and quite possibly MinGW \"pwd\") needs to be defined\n>    **before** it is called\n\nOK, I missed the first point, it seems.  But you seem to have missed that\nthese two problems are more or less independent---that is why I sent two\npatches, not a single ball of wax like the one I am responding to.\n\nSo the replacement for [PATCH 2/2] would now look like this?\n\nIn addition to \"applies fine, tested and works\" reports from Windows\nstakeholders, I still prefer to have a sign off from you (see\nDocumentation/SubmittingPatches).\n\nThanks.\n\n-- >8 --\nFrom: Steven Penny <svnpenn@gmail.com>\nDate: Wed, 16 May 2012 10:44:49 -0700\nSubject: [PATCH] git-sh-setup: work around Cygwin path handling gotchas\n\nOn Cygwin, tools built for Cygwin can take both Windows-style paths\n(e.g. C:/dir/file.txt or C:\\dir\\file.txt) and Cygwin-style paths\n(e.g. /cygdrive/c/dir/file.txt), but Windows-native tools can only take\nWindows-style paths.  Because the paths that are relative to $GIT_DIR,\ne.g. the name of the insn sheet file of the \"rebase -i\" command, are given\nto the programs with $GIT_DIR prefixed, and $GIT_DIR in turn is computed\nby calling \"pwd\", wrap \"pwd\" to call \"cygpath -m\" to give a Windows-style\npath, in a way similar to how mingw does this.\n---\n git-sh-setup.sh | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 770a86e..b8e6327 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -241,6 +241,11 @@ case $(uname -s) in\n \t\treturn 1\n \t}\n \t;;\n+*CYGWIN*)\n+\tpwd () {\n+\t\tcygpath -m \"$PWD\"\n+\t}\n+\t;;\n *)\n \tis_absolute_path () {\n \t\tcase \"$1\" in\n-- \n1.7.10.2.537.g0ac6509\n"},{"id":"191631","messageId":"4FB543B7.6000506@ramsay1.demon.co.uk","threadId":"30437","inReplyTo":"4FB340A9.60607@viscovery.net","subject":"Re: Git commit path vs rebase path","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-05-17T18:30:15Z","receivedAt":"2012-05-17T18:30:15Z","isPatch":false,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Johannes Sixt wrote:\n> Am 5/15/2012 19:32, schrieb Ramsay Jones:\n>>     ++ GIT_SEQUENCE_EDITOR=args\n>>     ++ eval args '\"$@\"'\n>>     +++ args /usr/home/ramsay/git/.git/rebase-merge/git-rebase-todo\n>>     argv[0] = 'C:\\msysgit\\msysgit\\home\\ramsay\\bin\\args.exe'\n>>     argv[1] = 'C:/msysgit/msysgit/home/ramsay/git/.git/rebase-merge/git-rebase-todo'\n> ...\n>> So, the msys \"path munging\" of program arguments saves the day!\n> \n> Absolutely. This path munging is an essential detail in the process.\n> \n> I don't know whether Cygwin has a similar feature, but I suppose not,\n> otherwise we wouldn't have received this issue report.\n\nYes, but I keep forgetting about this msys feature (I don't know why!).\nI've had this \"slap forehead\" moment 3 or 4 times already (why do you\nthink I have the args program close to hand? :-D ).\n\nAs you surmised, cygwin does not have this feature. On cygwin you are\nencouraged to use the cygpath utility in scripts. (Also, cygwin does\nprovide an API to convert to/from POSIX/win32 paths from your own\nprograms. eg. cygwin_conv_to_[full]_win32_path() and cygwin_conv_to_\\\n[full]_posix_path().)\n\n>From the cygwin user guide, in a section titled \"Using Cygwin effectively\nwith Windows\", we find this:\n\n    \"Windows programs do not understand POSIX pathnames, so any arguments\n    that reference the filesystem must be in Windows (or DOS) format or\n    translated. Cygwin provides the cygpath utility for converting\n    between Windows and POSIX paths. A complete description of its options\n    and examples of its usage are in Section 3.7.2, including a shell script\n    for starting Windows Explorer in any directory. The same format works\n    for most Windows programs, for example\n\n        notepad.exe \"$(cygpath -aw \"Desktop/Phone Numbers.txt\")\"\n\n    A few programs require a Windows-style, semicolon-delimited path list,\n    which cygpath can translate from a POSIX path with the -p option. For\n    example, a Java compilation from bash might look like this:\n\n        javac -cp \"$(cygpath -pw \"$CLASSPATH\")\" hello.java\n\n    Since using quoting and subshells is somewhat awkward, it is often\n    preferable to use cygpath in shell scripts.\"\n\nJust as an exercise, I created a script to use the windows PSPad editor\n(included below), using it to create a commit and also run this rebase:\n\n    GIT_EDITOR=pspad git rebase -i master uname\n\nBoth git commands launched the editor (and completed their task) just fine.\n\nNote that the script can be improved greatly, but it only took ten minutes\nto create and is sufficient to this task. (PSPad supports more than one file\non the command line, despite what it's help file says, although all options\napply to all files. You should be able to \"bundle\" the options ...).\n\n\nATB,\nRamsay Jones\n\n-- >8 --\n#!/bin/sh\n\nfile=\nopts=\n\nwhile test $# != 0\ndo\n    case \"$1\" in\n\t-[hH])\n\t    # open file in hex editor\n\t    opts=\"$opts /H\"\n\t    ;;\n\t-[rR])\n\t    # open file in read-only mode\n\t    opts=\"$opts /R\"\n\t    ;;\n\t-[0-9]*)\n\t    # open file and goto line n\n\t    opts=\"$opts /${1:1}\"\n\t    ;;\n\t-*)\n\t    echo \"option '$1' not supported\"\n\t    exit 1\n\t    ;;\n\t*)\n\t    if test -n \"$file\"; then\n\t\t    echo \"only one filename allowed\"\n\t\t    exit 1\n\t    fi\n\t    file=\"$1\"\n\t    ;;\n    esac\n    shift\ndone\n\nif test -n \"$file\"; then\n\tfile=\"$(cygpath -aw \"$file\")\"\nfi\n\n\"C:/Program Files/PSPad editor/PSPad.exe\" \"$file\" $opts\n\n-- 8< --\n"},{"id":"191633","messageId":"xmqqfwayobsq.fsf@junio.mtv.corp.google.com","threadId":"30437","inReplyTo":"4FB543B7.6000506@ramsay1.demon.co.uk","subject":"Re: Git commit path vs rebase path","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-17T19:19:33Z","receivedAt":"2012-05-17T19:19:33Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n\n> As you surmised, cygwin does not have this feature. On cygwin you are\n> encouraged to use the cygpath utility in scripts. (Also, cygwin does\n> provide an API to convert to/from POSIX/win32 paths from your own\n> programs. eg. cygwin_conv_to_[full]_win32_path() and cygwin_conv_to_\\\n> [full]_posix_path().)\n> ...\n> Just as an exercise, I created a script to use the windows PSPad editor\n> (included below), using it to create a commit and also run this rebase:\n>\n>     GIT_EDITOR=pspad git rebase -i master uname\n>\n> Both git commands launched the editor (and completed their task) just fine.\n\nSo where does the above leave us?\n\nYour message showed a way to \"solve\" it without changing git, but the\npresense of workaround alone is not a good reason not to change git, if\nthe change makes things better without breaking other things.  I'd like\nto know if Steven's patch breaks Cygwin users in other ways.\n\nSteven's message showed that spawning Cygwin programs and feeding paths\nin $GIT_DIR to them would not be broken if we start giving GIT_DIR as a\nWindows style path inside shell scripted Porcelains.  But will there be\nother things that get broken by the change?  An example of what would\nworry me is that we define has_drive_prefix() only for compat/mingw.h,\nso if somebody exports GIT_DIR back to call the binaries from scripted\nPorcelains, it is likely that it would break git running on Cygwin,\nwhere it expects only posix-style paths.  Upon seeing C:/foo/bar.txt, it\nwill start saying \"Ah, that is a relative path\" and may end up adding\nthe $(pwd) in front when it needs to know its absolute path.\n"},{"id":"191638","messageId":"4FB57D51.7050402@ramsay1.demon.co.uk","threadId":"30437","inReplyTo":"1337191208-21110-2-git-send-email-gitster@pobox.com","subject":"Re: [PATCH 1/2] git-sh-setup: define workaround wrappers before they are used","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-05-17T22:36:01Z","receivedAt":"2012-05-17T22:36:01Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Junio C Hamano wrote:\n> Recently we tweaked this scriptlet to let mingw port redefine \"pwd\" to\n> always return Windows-style path, but the code to do so came after the\n> first use of \"pwd\" to set up $GIT_DIR shell variable.\n> \n> Move the block to define these workaround wrappers, so that everything\n> everything that executes when the scriptlet is dot-sourced uses the\n> replacements.\n> \n> Noticed-by: Ramsay Jones\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  git-sh-setup.sh | 41 +++++++++++++++++++++--------------------\n>  1 file changed, 21 insertions(+), 20 deletions(-)\n> \n> diff --git a/git-sh-setup.sh b/git-sh-setup.sh\n> index 7b3ae75..770a86e 100644\n> --- a/git-sh-setup.sh\n> +++ b/git-sh-setup.sh\n> @@ -218,27 +218,8 @@ clear_local_git_env() {\n>  \tunset $(git rev-parse --local-env-vars)\n>  }\n>  \n> -# Make sure we are in a valid repository of a vintage we understand,\n> -# if we require to be in a git repository.\n> -if test -z \"$NONGIT_OK\"\n> -then\n> -\tGIT_DIR=$(git rev-parse --git-dir) || exit\n> -\tif [ -z \"$SUBDIRECTORY_OK\" ]\n> -\tthen\n> -\t\ttest -z \"$(git rev-parse --show-cdup)\" || {\n> -\t\t\texit=$?\n> -\t\t\techo >&2 \"You need to run this command from the toplevel of the working tree.\"\n> -\t\t\texit $exit\n> -\t\t}\n> -\tfi\n> -\ttest -n \"$GIT_DIR\" && GIT_DIR=$(cd \"$GIT_DIR\" && pwd) || {\n> -\t\techo >&2 \"Unable to determine absolute path of git directory\"\n> -\t\texit 1\n> -\t}\n> -\t: ${GIT_OBJECT_DIRECTORY=\"$GIT_DIR/objects\"}\n> -fi\n>  \n> -# Fix some commands on Windows\n> +# Platform specific tweaks to work around some commands\n>  case $(uname -s) in\n>  *MINGW*)\n>  \t# Windows has its own (incompatible) sort and find\n> @@ -269,3 +250,23 @@ case $(uname -s) in\n>  \t\treturn 1\n>  \t}\n>  esac\n> +\n> +# Make sure we are in a valid repository of a vintage we understand,\n> +# if we require to be in a git repository.\n> +if test -z \"$NONGIT_OK\"\n> +then\n> +\tGIT_DIR=$(git rev-parse --git-dir) || exit\n> +\tif [ -z \"$SUBDIRECTORY_OK\" ]\n> +\tthen\n> +\t\ttest -z \"$(git rev-parse --show-cdup)\" || {\n> +\t\t\texit=$?\n> +\t\t\techo >&2 \"You need to run this command from the toplevel of the working tree.\"\n> +\t\t\texit $exit\n> +\t\t}\n> +\tfi\n> +\ttest -n \"$GIT_DIR\" && GIT_DIR=$(cd \"$GIT_DIR\" && pwd) || {\n> +\t\techo >&2 \"Unable to determine absolute path of git directory\"\n> +\t\texit 1\n> +\t}\n> +\t: ${GIT_OBJECT_DIRECTORY=\"$GIT_DIR/objects\"}\n> +fi\n\nThanks for doing this. (I would have got around to it, honest! However, it does\nsolve a minor problem for me, since I kinda promised not to post anymore MinGW\nspecific patches. :-D ).\n\nI have not done a full test on this patch; I have only run the following tests\non MinGW and cygwin:\n\n    $ git grep -l -e 'git *submodule' -- t\n    t/t5526-fetch-submodules.sh\n    t/t6008-rev-list-submodule.sh\n    t/t7003-filter-branch.sh\n    t/t7400-submodule-basic.sh\n    t/t7401-submodule-summary.sh\n    t/t7403-submodule-sync.sh\n    t/t7405-submodule-merge.sh\n    t/t7406-submodule-update.sh\n    t/t7407-submodule-foreach.sh\n    t/t7408-submodule-reference.sh\n    t/t7506-status-submodule.sh\n    t/t7610-mergetool.sh\n    t/t9300-fast-import.sh\n    t/t9350-fast-export.sh\n\n(On MinGW i have to use a \"GIT_TEST_CMP='diff -ub'\" prefix, otherwise there are\nsome failures caused by \"lf/crlf line ending\" problems).\n\nAll of these tests pass. I don't anticipate any problems (especially on cygwin,\nsince it is essentially a noop there), but I have not done a complete test.\n\nI probably won't get to it soon, so I'm hoping somebody can beat me to it!\n\nATB,\nRamsay Jones\n"},{"id":"191639","messageId":"4FB58678.1050009@ramsay1.demon.co.uk","threadId":"30437","inReplyTo":"7vd364c5kt.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] git-sh-setup: work around Cygwin path handling gotchas","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-05-17T23:15:04Z","receivedAt":"2012-05-17T23:15:04Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Junio C Hamano wrote:\n> Steven Penny <svnpenn@gmail.com> writes:\n> \n>> Junio C Hamano wrote:\n>>> +*CYGWIN*)\n>>> +       pwd () {\n>>> +               builtin cygpath -m\n>>> +       }\n>>> +       ;;\n>> Ok I got it!\n>>\n>> The problem is twofold\n>>\n>> 1. Ramsay Jones\twas right, it needs to be called like\n>>\n>> \tcygpath -m \"$PWD\"\n>>\n>> 2. The Cygwin \"pwd\" (and quite possibly MinGW \"pwd\") needs to be defined\n>>    **before** it is called\n> \n> OK, I missed the first point, it seems.  But you seem to have missed that\n> these two problems are more or less independent---that is why I sent two\n> patches, not a single ball of wax like the one I am responding to.\n> \n> So the replacement for [PATCH 2/2] would now look like this?\n> \n> In addition to \"applies fine, tested and works\" reports from Windows\n> stakeholders, I still prefer to have a sign off from you (see\n> Documentation/SubmittingPatches).\n> \n> Thanks.\n> \n> -- >8 --\n> From: Steven Penny <svnpenn@gmail.com>\n> Date: Wed, 16 May 2012 10:44:49 -0700\n> Subject: [PATCH] git-sh-setup: work around Cygwin path handling gotchas\n> \n> On Cygwin, tools built for Cygwin can take both Windows-style paths\n> (e.g. C:/dir/file.txt or C:\\dir\\file.txt) and Cygwin-style paths\n> (e.g. /cygdrive/c/dir/file.txt), but Windows-native tools can only take\n> Windows-style paths.  Because the paths that are relative to $GIT_DIR,\n> e.g. the name of the insn sheet file of the \"rebase -i\" command, are given\n> to the programs with $GIT_DIR prefixed, and $GIT_DIR in turn is computed\n> by calling \"pwd\", wrap \"pwd\" to call \"cygpath -m\" to give a Windows-style\n> path, in a way similar to how mingw does this.\n> ---\n>  git-sh-setup.sh | 5 +++++\n>  1 file changed, 5 insertions(+)\n> \n> diff --git a/git-sh-setup.sh b/git-sh-setup.sh\n> index 770a86e..b8e6327 100644\n> --- a/git-sh-setup.sh\n> +++ b/git-sh-setup.sh\n> @@ -241,6 +241,11 @@ case $(uname -s) in\n>  \t\treturn 1\n>  \t}\n>  \t;;\n> +*CYGWIN*)\n> +\tpwd () {\n> +\t\tcygpath -m \"$PWD\"\n> +\t}\n> +\t;;\n>  *)\n>  \tis_absolute_path () {\n>  \t\tcase \"$1\" in\n\nI guess you won't be shocked to hear that I don't think this patch is\nnecessary. :-P\n\nHowever, I can appreciate that some people would rather not have to\ncreate a shell script to wrap their text editor, just to use git.\nSo I'm certainly not opposed to finding a solution to this problem\nthat doesn't require the user to do so.\n\nMy concerns about this patch include:\n\n    - the additional fork+exec overhead associated with calling cygpath.\n      I'm not actually claiming there is any substantial increase; I\n      haven't tried it, so I don't know how \"hot\" the pwd() function is.\n\n    - this is a \"big hammer\" which will affect much more code that is\n      required to fix this problem.\n\nThe latter is my main concern. I would rather have the call to cygpath\nat the point in the code where the editor is launched. This would reduce\nthe scope of the change and any side-effects that go with it.\n\nAnyway, I applied this patch tonight to give it a go. The very first test\nI tried failed. I've attached the log of the failing test below.\nNote that it is attempting to use \"ssh\" to a \"host\" that ends in \".../C:\".\n\nI haven't investigated yet (I've got to get some sleep).\n\nHTH\n\nATB,\nRamsay Jones\n\n\nexpecting success:\n        (\n                cd addtest &&\n                git submodule add ../repo relative &&\n                test \"$(git config -f .gitmodules submodule.relative.url)\" = ../\nrepo &&\n                git submodule sync relative &&\n                test \"$(git config submodule.relative.url)\" = \"$submodurl/repo\"\n        )\n\nCloning into 'relative'...\nssh: /home/ramsay/git/t/trash directory.t7400-submodule-basic/addtest/C: no addr\ness associated with name\nfatal: The remote end hung up unexpectedly\nClone of 'C:/cygwin/home/ramsay/git/t/trash directory.t7400-submodule-basic/repo\n' into submodule path 'relative' failed\nnot ok - 41 use superproject as upstream when path is relative and no url is set\n there\n#\n#               (\n#                       cd addtest &&\n#                       git submodule add ../repo relative &&\n#                       test \"$(git config -f .gitmodules submodule.relative.url\n)\" = ../repo &&\n#                       git submodule sync relative &&\n#                       test \"$(git config submodule.relative.url)\" = \"$submodur\nl/repo\"\n#               )\n#\n$\n"},{"id":"191642","messageId":"7vehqib4kk.fsf@alter.siamese.dyndns.org","threadId":"30437","inReplyTo":"4FB58678.1050009@ramsay1.demon.co.uk","subject":"Re: [PATCH 2/2] git-sh-setup: work around Cygwin path handling gotchas","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-18T02:34:03Z","receivedAt":"2012-05-18T02:34:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n\n> I guess you won't be shocked to hear that I don't think this patch is\n> necessary. :-P\n\nThat is more or less irrelevant, not in the sense that what you say is\nirrelevant, but in the sense that something can be worked around in a\ndifferent way alone is not a good reason to reject a patch, if its benefit\noutweigh its costs.\n\nThe more important message for you to respond to is this one:\n\n    Subject: Re: Git commit path vs rebase path\n    To: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n    Cc: Johannes Sixt <j.sixt@viscovery.net>,\n            Steven Penny <svnpenn@gmail.com>,\n            Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org\n    Date: Thu, 17 May 2012 12:19:33 -0700\n    Message-ID: <xmqqfwayobsq.fsf@junio.mtv.corp.google.com>\n\n> My concerns about this patch include:\n>\n>     - the additional fork+exec overhead associated with calling cygpath.\n>       I'm not actually claiming there is any substantial increase; I\n>       haven't tried it, so I don't know how \"hot\" the pwd() function is.\n>\n>     - this is a \"big hammer\" which will affect much more code that is\n>       required to fix this problem.\n\nIf I speculated in the other message is correct (in short, \"In Cygwin\nworld, Git is compiled to use POSIX paths and would not work with Windows\npaths.\"), I think this \"problem\" is fundamentally un\"fix\"able.\n\nAnd from Cygwin Git, your programs (like $EDITOR and hooks) will get POSIX\npaths.  It is your programs' responsibility to turn them into Windows\npaths if/as necessary.\n\n> Anyway, I applied this patch tonight to give it a go. The very first test\n> I tried failed. I've attached the log of the failing test below.\n> Note that it is attempting to use \"ssh\" to a \"host\" that ends in \".../C:\".\n\nOf course.  That is one typical symptom that suggests my speculation was\ncorrect.\n\nSo \"I don't think this patch is necessary\" is irrelevant, but \"This patch\nis harmful; Git on Cygwin is never supposed to use Windows paths\" is very\nrelevant ;-)\n"},{"id":"191707","messageId":"CAAXzdLU2t64x0jk_QHjwBDP2OPEeVqipT6uaivikn=6F6aieAA@mail.gmail.com","threadId":"30437","inReplyTo":"7vehqib4kk.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] git-sh-setup: work around Cygwin path handling gotchas","fromName":"Steven Penny","fromEmail":"svnpenn@gmail.com","sentAt":"2012-05-19T00:43:54Z","receivedAt":"2012-05-19T00:43:54Z","isPatch":true,"sender":{"key":"svnpenn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/60531334?v=4"},"body":"On Thu, May 17, 2012 at 9:34 PM, Junio C Hamano wrote:\n> And from Cygwin Git, your programs (like $EDITOR and hooks) will get POSIX\n> paths.  It is your programs' responsibility to turn them into Windows\n> paths if/as necessary.\n\nI think this is correct. These program should be accepting Cygwin paths and are\nnot for obvious reason, they exist outside the the Cygwin world.\n\nFor now I will do something like this\n\n\teditor(){\n\t\tcygpath -m \"$1\" | xargs notepad\n\t}\n\n\texport -f editor\n\t\n\tgit config core.editor editor\n"},{"id":"191822","messageId":"4FBA8CD4.3020001@ramsay1.demon.co.uk","threadId":"30437","inReplyTo":"7vehqib4kk.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] git-sh-setup: work around Cygwin path handling gotchas","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-05-21T18:43:32Z","receivedAt":"2012-05-21T18:43:32Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Junio C Hamano wrote:\n> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n> \n>> I guess you won't be shocked to hear that I don't think this patch is\n>> necessary. :-P\n> \n> That is more or less irrelevant, not in the sense that what you say is\n> irrelevant, but in the sense that something can be worked around in a\n> different way alone is not a good reason to reject a patch, if its benefit\n> outweigh its costs.\n\nI completely agree.\n\nIn case it was not clear, I was not suggesting that the patch be rejected on\nthe basis that the problem could be worked around in a different way.\n\n> If I speculated in the other message is correct (in short, \"In Cygwin\n> world, Git is compiled to use POSIX paths and would not work with Windows\n> paths.\"), I think this \"problem\" is fundamentally un\"fix\"able.\n\nYes, Cygwin is essentially just another POSIX target as far as Git is\nconcerned. Cygwin tries hard to provide a POSIX-like environment, but it is\nnot possible for it to completely hide the fact that the base OS is not\nactually a POSIX system.\n \n> And from Cygwin Git, your programs (like $EDITOR and hooks) will get POSIX\n> paths.  It is your programs' responsibility to turn them into Windows\n> paths if/as necessary.\n\nI would say that this is the only sensible way to proceed.\n\nHowever, you could imagine adding code to accommodate external windows\nprograms. If we limit ourselves to the text editor, for example, I could\nimagine something like the diff attached below to fix up the C based git\nprograms. (You would need to make similar changes to the shell and perl\nscripts which launch the text editor).\n\nI would not like to see a patch based on this (or any others like it) applied,\nsince it is going in the wrong direction. (Why do people use Cygwin git rather\nthan MinGW git and vice versa). Of course, it is not my decision to make ... :-P\n\n>> Anyway, I applied this patch tonight to give it a go. The very first test\n>> I tried failed. I've attached the log of the failing test below.\n>> Note that it is attempting to use \"ssh\" to a \"host\" that ends in \".../C:\".\n> \n> Of course.  That is one typical symptom that suggests my speculation was\n> correct.\n\nHeh, I was surprised that it did as well as it did; after all, it passed 44\nout of the 45 tests run (from t7400-submodule-basic.sh). ;-)\n\n> So \"I don't think this patch is necessary\" is irrelevant, but \"This patch\n> is harmful; Git on Cygwin is never supposed to use Windows paths\" is very\n> relevant ;-)\n\nI agree.\n\nATB,\nRamsay Jones\n\n-- >8 --\ndiff --git a/editor.c b/editor.c\nindex d834003..cf36e62 100644\n--- a/editor.c\n+++ b/editor.c\n@@ -1,6 +1,9 @@\n #include \"cache.h\"\n #include \"strbuf.h\"\n #include \"run-command.h\"\n+#ifdef __CYGWIN__\n+# include <sys/cygwin.h>\n+#endif\n \n #ifndef DEFAULT_EDITOR\n #define DEFAULT_EDITOR \"vi\"\n@@ -37,6 +40,12 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en\n \n \tif (strcmp(editor, \":\")) {\n \t\tconst char *args[] = { editor, path, NULL };\n+#ifdef __CYGWIN__\n+\t\tchar win32_path[1024];\n+\n+\t\tcygwin_conv_to_full_win32_path(path, win32_path);\n+\t\targs[1] = win32_path;\n+#endif\n \n \t\tif (run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env))\n \t\t\treturn error(\"There was a problem with the editor '%s'.\",\n-- 8< --\n"},{"id":"191843","messageId":"7vaa116ulx.fsf@alter.siamese.dyndns.org","threadId":"30437","inReplyTo":"4FBA8CD4.3020001@ramsay1.demon.co.uk","subject":"Re: [PATCH 2/2] git-sh-setup: work around Cygwin path handling gotchas","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-05-21T22:24:10Z","receivedAt":"2012-05-21T22:24:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n\n> However, you could imagine adding code to accommodate external windows\n> programs. If we limit ourselves to the text editor, for example, I could\n> imagine something like the diff attached below to fix up the C based git\n> programs. (You would need to make similar changes to the shell and perl\n> scripts which launch the text editor).\n\nIf you _only_ allow editors that understands windows style paths, your\npatch may make sense, but doesn't it break editors that wants only POSIX\nstyle paths?\n\n>\n> ATB,\n> Ramsay Jones\n>\n> -- >8 --\n> diff --git a/editor.c b/editor.c\n> index d834003..cf36e62 100644\n> --- a/editor.c\n> +++ b/editor.c\n> @@ -1,6 +1,9 @@\n>  #include \"cache.h\"\n>  #include \"strbuf.h\"\n>  #include \"run-command.h\"\n> +#ifdef __CYGWIN__\n> +# include <sys/cygwin.h>\n> +#endif\n>  \n>  #ifndef DEFAULT_EDITOR\n>  #define DEFAULT_EDITOR \"vi\"\n> @@ -37,6 +40,12 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en\n>  \n>  \tif (strcmp(editor, \":\")) {\n>  \t\tconst char *args[] = { editor, path, NULL };\n> +#ifdef __CYGWIN__\n> +\t\tchar win32_path[1024];\n> +\n> +\t\tcygwin_conv_to_full_win32_path(path, win32_path);\n> +\t\targs[1] = win32_path;\n> +#endif\n>  \n>  \t\tif (run_command_v_opt_cd_env(args, RUN_USING_SHELL, NULL, env))\n>  \t\t\treturn error(\"There was a problem with the editor '%s'.\",\n> -- 8< --\n"},{"id":"192096","messageId":"4FBE7DA9.8040309@ramsay1.demon.co.uk","threadId":"30437","inReplyTo":"7vaa116ulx.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 2/2] git-sh-setup: work around Cygwin path handling gotchas","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2012-05-24T18:27:53Z","receivedAt":"2012-05-24T18:27:53Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Junio C Hamano wrote:\n> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n> \n>> However, you could imagine adding code to accommodate external windows\n>> programs. If we limit ourselves to the text editor, for example, I could\n>> imagine something like the diff attached below to fix up the C based git\n>> programs. (You would need to make similar changes to the shell and perl\n>> scripts which launch the text editor).\n> \n> If you _only_ allow editors that understands windows style paths, your\n> patch may make sense, but doesn't it break editors that wants only POSIX\n> style paths?\n\nYes.\n\n(If it wasn't clear, I included the code to show what I *didn't* want to see!).\n\nCygwin built text editors will, of course, work fine with POSIX paths, but\nmay also work with win32 paths as well. For example, vim supports win32 paths\njust fine (it's the *only* editor I tested).\n\nI would not be surprised if vim is not alone in that; I think it mainly depends\non whether the editor attempts to \"interpret\" the parameter, or simply treats it\nas an opaque token to be passed straight to [f]open() [1].\n\nEqually, I suspect some cygwin built editors will fail miserably (maybe they try\nto interpret the parameter as an scp-like url, say). I don't know and I'm not\nabout to test every cygwin text editor to find out!\n\nSo, in my opinion, adding code to explicitly support win32 paths, while possible,\nis likely to open up a can-o-worms (even if this support were opt-in via config).\nI would prefer that we don't go there. :-D\n\n\nATB,\nRamsay Jones\n\n[1] Which is why git already supports win32 paths to a certain degree. For example,\nthe following will work as expected:\n\n  $ git config --global core.excludesfile 'C:/cygwin/home/ramsay/.gitignore'\n\n(ie git will read and use the given .gitignore file without problem)\n"}]}