{"thread":{"id":"33632","subject":"[PATCH] git-gui: fix file name handling with non-empty prefix","startedAt":"2013-04-27T13:24:16Z","lastAt":"2013-05-30T15:55:02Z","messageCount":4,"participants":["John Keeping","Andrew Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"215703","messageId":"264998b2b2201b7d6ab9bfa8b5518f712b3a6a08.1367069056.git.john@keeping.me.uk","threadId":"33632","inReplyTo":null,"subject":"[PATCH] git-gui: fix file name handling with non-empty prefix","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-04-27T13:24:16Z","receivedAt":"2013-04-27T13:24:16Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"Commit e3d06ca (git-gui: Detect full path when parsing arguments -\n2012-10-02) fixed the handling of absolute paths passed to the browser\nand blame subcommands by checking whether the file exists without the\nprefix before prepending the prefix and checking again.  Since we have\nchdir'd to the top level of the working tree before doing this, this\ndoes not work if a file with the same name exists in a subdirectory and\nat the top level (for example Makefile in git.git's t/ directory).\n\nInstead of doing this, revert that patch and fix absolute path issue by\nusing \"file join\" to prepend the prefix to the supplied path.  This will\ncorrectly handle absolute paths by skipping the prefix in that case.\n\nSigned-off-by: John Keeping <john@keeping.me.uk>\n---\n git-gui.sh | 14 +++-----------\n 1 file changed, 3 insertions(+), 11 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex e133331..a94ad7f 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -3003,19 +3003,11 @@ blame {\n \tset jump_spec {}\n \tset is_path 0\n \tforeach a $argv {\n-\t\tif {[file exists $a]} {\n-\t\t\tif {$path ne {}} usage\n-\t\t\tset path [normalize_relpath $a]\n-\t\t\tbreak\n-\t\t} elseif {[file exists $_prefix$a]} {\n-\t\t\tif {$path ne {}} usage\n-\t\t\tset path [normalize_relpath $_prefix$a]\n-\t\t\tbreak\n-\t\t}\n+\t\tset p [file join $_prefix $a]\n \n-\t\tif {$is_path} {\n+\t\tif {$is_path || [file exists $p]} {\n \t\t\tif {$path ne {}} usage\n-\t\t\tset path [normalize_relpath $_prefix$a]\n+\t\t\tset path [normalize_relpath $p]\n \t\t\tbreak\n \t\t} elseif {$a eq {--}} {\n \t\t\tif {$path ne {}} {\n-- \n1.8.3.rc0.149.g98a72f2.dirty\n"},{"id":"215709","messageId":"20130427141839.GF472@serenity.lan","threadId":"33632","inReplyTo":"264998b2b2201b7d6ab9bfa8b5518f712b3a6a08.1367069056.git.john@keeping.me.uk","subject":"Re: [PATCH] git-gui: fix file name handling with non-empty prefix","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-04-27T14:18:39Z","receivedAt":"2013-04-27T14:18:39Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"I got a bounce with \"550 no such user\" for Pat's email address when\nsending this.  Does anyone have more up-to-date contact details?  Or is\nit just SourceForge being broken?\n\nOn Sat, Apr 27, 2013 at 02:24:16PM +0100, John Keeping wrote:\n> Commit e3d06ca (git-gui: Detect full path when parsing arguments -\n> 2012-10-02) fixed the handling of absolute paths passed to the browser\n> and blame subcommands by checking whether the file exists without the\n> prefix before prepending the prefix and checking again.  Since we have\n> chdir'd to the top level of the working tree before doing this, this\n> does not work if a file with the same name exists in a subdirectory and\n> at the top level (for example Makefile in git.git's t/ directory).\n> \n> Instead of doing this, revert that patch and fix absolute path issue by\n> using \"file join\" to prepend the prefix to the supplied path.  This will\n> correctly handle absolute paths by skipping the prefix in that case.\n> \n> Signed-off-by: John Keeping <john@keeping.me.uk>\n> ---\n>  git-gui.sh | 14 +++-----------\n>  1 file changed, 3 insertions(+), 11 deletions(-)\n> \n> diff --git a/git-gui.sh b/git-gui.sh\n> index e133331..a94ad7f 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -3003,19 +3003,11 @@ blame {\n>  \tset jump_spec {}\n>  \tset is_path 0\n>  \tforeach a $argv {\n> -\t\tif {[file exists $a]} {\n> -\t\t\tif {$path ne {}} usage\n> -\t\t\tset path [normalize_relpath $a]\n> -\t\t\tbreak\n> -\t\t} elseif {[file exists $_prefix$a]} {\n> -\t\t\tif {$path ne {}} usage\n> -\t\t\tset path [normalize_relpath $_prefix$a]\n> -\t\t\tbreak\n> -\t\t}\n> +\t\tset p [file join $_prefix $a]\n>  \n> -\t\tif {$is_path} {\n> +\t\tif {$is_path || [file exists $p]} {\n>  \t\t\tif {$path ne {}} usage\n> -\t\t\tset path [normalize_relpath $_prefix$a]\n> +\t\t\tset path [normalize_relpath $p]\n>  \t\t\tbreak\n>  \t\t} elseif {$a eq {--}} {\n>  \t\t\tif {$path ne {}} {\n> -- \n> 1.8.3.rc0.149.g98a72f2.dirty\n"},{"id":"217054","messageId":"518EF86D.3060207@gmail.com","threadId":"33632","inReplyTo":"20130427141839.GF472@serenity.lan","subject":"Re: [PATCH] git-gui: fix file name handling with non-empty prefix","fromName":"Andrew Wong","fromEmail":"andrew.kw.w@gmail.com","sentAt":"2013-05-12T02:03:25Z","receivedAt":"2013-05-12T02:03:25Z","isPatch":true,"sender":{"key":"andrew.kw.w@gmail.com","avatar":"https://avatars.githubusercontent.com/u/489311?v=4"},"body":"Sorry for the late reply. I was able to reproduce the problem that you\nwere describing a while ago. And your patch indeed fixes it. It's a much\nmore elegant way of dealing with the \"absolute vs relative\" path problem\nthat I was trying to fix.\n\nThanks!\n\nAs for Pat, I'm not sure wha'ts going on with his email address. It was\nworking back in October, and his username still seems to be active over\nat SourceForge... let's see if this email reaches him.\n\nHere's a link for his reference just in case he missed your original email:\nhttp://thread.gmane.org/gmane.comp.version-control.git/222646\n\n\nOn 04/27/13 10:18, John Keeping wrote:\n> I got a bounce with \"550 no such user\" for Pat's email address when\n> sending this.  Does anyone have more up-to-date contact details?  Or is\n> it just SourceForge being broken?\n>\n> On Sat, Apr 27, 2013 at 02:24:16PM +0100, John Keeping wrote:\n>> Commit e3d06ca (git-gui: Detect full path when parsing arguments -\n>> 2012-10-02) fixed the handling of absolute paths passed to the browser\n>> and blame subcommands by checking whether the file exists without the\n>> prefix before prepending the prefix and checking again.  Since we have\n>> chdir'd to the top level of the working tree before doing this, this\n>> does not work if a file with the same name exists in a subdirectory and\n>> at the top level (for example Makefile in git.git's t/ directory).\n>>\n>> Instead of doing this, revert that patch and fix absolute path issue by\n>> using \"file join\" to prepend the prefix to the supplied path.  This will\n>> correctly handle absolute paths by skipping the prefix in that case.\n>>\n>> Signed-off-by: John Keeping <john@keeping.me.uk>\n>> ---\n>>  git-gui.sh | 14 +++-----------\n>>  1 file changed, 3 insertions(+), 11 deletions(-)\n>>\n>> diff --git a/git-gui.sh b/git-gui.sh\n>> index e133331..a94ad7f 100755\n>> --- a/git-gui.sh\n>> +++ b/git-gui.sh\n>> @@ -3003,19 +3003,11 @@ blame {\n>>  \tset jump_spec {}\n>>  \tset is_path 0\n>>  \tforeach a $argv {\n>> -\t\tif {[file exists $a]} {\n>> -\t\t\tif {$path ne {}} usage\n>> -\t\t\tset path [normalize_relpath $a]\n>> -\t\t\tbreak\n>> -\t\t} elseif {[file exists $_prefix$a]} {\n>> -\t\t\tif {$path ne {}} usage\n>> -\t\t\tset path [normalize_relpath $_prefix$a]\n>> -\t\t\tbreak\n>> -\t\t}\n>> +\t\tset p [file join $_prefix $a]\n>>  \n>> -\t\tif {$is_path} {\n>> +\t\tif {$is_path || [file exists $p]} {\n>>  \t\t\tif {$path ne {}} usage\n>> -\t\t\tset path [normalize_relpath $_prefix$a]\n>> +\t\t\tset path [normalize_relpath $p]\n>>  \t\t\tbreak\n>>  \t\t} elseif {$a eq {--}} {\n>>  \t\t\tif {$path ne {}} {\n>> -- \n>> 1.8.3.rc0.149.g98a72f2.dirty\n"},{"id":"219025","messageId":"20130530155502.GE17475@serenity.lan","threadId":"33632","inReplyTo":"518EF86D.3060207@gmail.com","subject":"Re: [PATCH] git-gui: fix file name handling with non-empty prefix","fromName":"John Keeping","fromEmail":"john@keeping.me.uk","sentAt":"2013-05-30T15:55:02Z","receivedAt":"2013-05-30T15:55:02Z","isPatch":true,"sender":{"key":"john@keeping.me.uk","avatar":"https://avatars.githubusercontent.com/u/1702081?v=4"},"body":"In the hope that the Pat Thoyts who just posted in another thread from a\nGMail address is the same one that maintains git-gui, let's see if that\naddress works...\n\nOn Sat, May 11, 2013 at 10:03:25PM -0400, Andrew Wong wrote:\n> Sorry for the late reply. I was able to reproduce the problem that you\n> were describing a while ago. And your patch indeed fixes it. It's a much\n> more elegant way of dealing with the \"absolute vs relative\" path problem\n> that I was trying to fix.\n> \n> Thanks!\n> \n> As for Pat, I'm not sure wha'ts going on with his email address. It was\n> working back in October, and his username still seems to be active over\n> at SourceForge... let's see if this email reaches him.\n> \n> Here's a link for his reference just in case he missed your original email:\n> http://thread.gmane.org/gmane.comp.version-control.git/222646\n> \n> \n> On 04/27/13 10:18, John Keeping wrote:\n> > I got a bounce with \"550 no such user\" for Pat's email address when\n> > sending this.  Does anyone have more up-to-date contact details?  Or is\n> > it just SourceForge being broken?\n> >\n> > On Sat, Apr 27, 2013 at 02:24:16PM +0100, John Keeping wrote:\n> >> Commit e3d06ca (git-gui: Detect full path when parsing arguments -\n> >> 2012-10-02) fixed the handling of absolute paths passed to the browser\n> >> and blame subcommands by checking whether the file exists without the\n> >> prefix before prepending the prefix and checking again.  Since we have\n> >> chdir'd to the top level of the working tree before doing this, this\n> >> does not work if a file with the same name exists in a subdirectory and\n> >> at the top level (for example Makefile in git.git's t/ directory).\n> >>\n> >> Instead of doing this, revert that patch and fix absolute path issue by\n> >> using \"file join\" to prepend the prefix to the supplied path.  This will\n> >> correctly handle absolute paths by skipping the prefix in that case.\n> >>\n> >> Signed-off-by: John Keeping <john@keeping.me.uk>\n> >> ---\n> >>  git-gui.sh | 14 +++-----------\n> >>  1 file changed, 3 insertions(+), 11 deletions(-)\n> >>\n> >> diff --git a/git-gui.sh b/git-gui.sh\n> >> index e133331..a94ad7f 100755\n> >> --- a/git-gui.sh\n> >> +++ b/git-gui.sh\n> >> @@ -3003,19 +3003,11 @@ blame {\n> >>  \tset jump_spec {}\n> >>  \tset is_path 0\n> >>  \tforeach a $argv {\n> >> -\t\tif {[file exists $a]} {\n> >> -\t\t\tif {$path ne {}} usage\n> >> -\t\t\tset path [normalize_relpath $a]\n> >> -\t\t\tbreak\n> >> -\t\t} elseif {[file exists $_prefix$a]} {\n> >> -\t\t\tif {$path ne {}} usage\n> >> -\t\t\tset path [normalize_relpath $_prefix$a]\n> >> -\t\t\tbreak\n> >> -\t\t}\n> >> +\t\tset p [file join $_prefix $a]\n> >>  \n> >> -\t\tif {$is_path} {\n> >> +\t\tif {$is_path || [file exists $p]} {\n> >>  \t\t\tif {$path ne {}} usage\n> >> -\t\t\tset path [normalize_relpath $_prefix$a]\n> >> +\t\t\tset path [normalize_relpath $p]\n> >>  \t\t\tbreak\n> >>  \t\t} elseif {$a eq {--}} {\n> >>  \t\t\tif {$path ne {}} {\n> >> -- \n> >> 1.8.3.rc0.149.g98a72f2.dirty\n> \n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"}]}