{"thread":{"id":"31715","subject":"[PATCH 2/2] git-gui: Don't prepend the prefix if value looks like a full path","startedAt":"2012-10-02T16:25:13Z","lastAt":"2012-10-12T14:08:02Z","messageCount":5,"participants":["Andrew Wong"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"200335","messageId":"1349195115-15494-1-git-send-email-andrew.kw.w@gmail.com","threadId":"31715","inReplyTo":null,"subject":"[PATCH] git-gui: Few issues with using full path name","fromName":"Andrew Wong","fromEmail":"andrew.kw.w@gmail.com","sentAt":"2012-10-02T16:25:13Z","receivedAt":"2012-10-02T16:25:13Z","isPatch":true,"sender":{"key":"andrew.kw.w@gmail.com","avatar":"https://avatars.githubusercontent.com/u/489311?v=4"},"body":"I ran into a file name parsing issue in git-gui. If I'm in a subfolder and try\nto pass a full path to \"git-gui blame\", then \"git-gui\" will fail to detect the\nargument as a valid path. The first patch will handle this scenario.\n\nThe second patch just another issue that I noticed when \"git-gui\" fails to\ndetect the file name. It'll then try to use the previously detected \"head\" as\nthe file name, while prepending it with \"prefix\". This is incorrect if \"head\"\nis actually a full path.\n\nThere is also an issue when using a full path along with a rev argument, but I\ndon't have time to look it right now. I'll try to get to that issue another\ntime.\n\nAndrew Wong (2):\n  git-gui: Detect full path when parsing arguments\n  git-gui: Don't prepend the prefix if value looks like a full path\n\n git-gui.sh | 20 +++++++++++++++++---\n 1 file changed, 17 insertions(+), 3 deletions(-)\n\n-- \n1.7.12.1.382.gb0576a6\n"},{"id":"200334","messageId":"1349195115-15494-2-git-send-email-andrew.kw.w@gmail.com","threadId":"31715","inReplyTo":"1349195115-15494-1-git-send-email-andrew.kw.w@gmail.com","subject":"[PATCH 1/2] git-gui: Detect full path when parsing arguments","fromName":"Andrew Wong","fromEmail":"andrew.kw.w@gmail.com","sentAt":"2012-10-02T16:25:14Z","receivedAt":"2012-10-02T16:25:14Z","isPatch":true,"sender":{"key":"andrew.kw.w@gmail.com","avatar":"https://avatars.githubusercontent.com/u/489311?v=4"},"body":"When running \"git-gui blame\" from a subfolder (which means prefix is\nnon-empty), if we pass a full path as argument, the argument parsing\nwill fail to recognize the argument as a file name, because prefix is\nprepended to the argument.\n\nThis patch handles that scenario by adding an additional branch that\nchecks the file name without using the prefix.\n\nSigned-off-by: Andrew Wong <andrew.kw.w@gmail.com>\n---\n git-gui.sh | 11 ++++++++++-\n 1 file changed, 10 insertions(+), 1 deletion(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex 5d035d5..5d7894b 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -3003,10 +3003,19 @@ blame {\n \tset jump_spec {}\n \tset is_path 0\n \tforeach a $argv {\n-\t\tif {$is_path || [file exists $_prefix$a]} {\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+\n+\t\tif {$is_path} {\n+\t\t\tif {$path ne {}} usage\n+\t\t\tbreak\n \t\t} elseif {$a eq {--}} {\n \t\t\tif {$path ne {}} {\n \t\t\t\tif {$head ne {}} usage\n-- \n1.7.12.1.382.gb0576a6\n"},{"id":"200333","messageId":"1349195115-15494-3-git-send-email-andrew.kw.w@gmail.com","threadId":"31715","inReplyTo":"1349195115-15494-1-git-send-email-andrew.kw.w@gmail.com","subject":"[PATCH 2/2] git-gui: Don't prepend the prefix if value looks like a full path","fromName":"Andrew Wong","fromEmail":"andrew.kw.w@gmail.com","sentAt":"2012-10-02T16:25:15Z","receivedAt":"2012-10-02T16:25:15Z","isPatch":true,"sender":{"key":"andrew.kw.w@gmail.com","avatar":"https://avatars.githubusercontent.com/u/489311?v=4"},"body":"When argument parsing fails to detect a file name, \"git-gui\" will try to\nuse the previously detected \"head\" as the file name. We should avoid\nprepending the prefix if \"head\" looks like a full path.\n\nSigned-off-by: Andrew Wong <andrew.kw.w@gmail.com>\n---\n git-gui.sh | 9 +++++++--\n 1 file changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex 5d7894b..89f636f 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -3037,8 +3037,13 @@ blame {\n \tunset is_path\n \n \tif {$head ne {} && $path eq {}} {\n-\t\tset path [normalize_relpath $_prefix$head]\n-\t\tset head {}\n+\t\tif {[string index $head 0] eq {/}} {\n+\t\t\tset path [normalize_relpath $head]\n+\t\t\tset head {}\n+\t\t} else {\n+\t\t\tset path [normalize_relpath $_prefix$head]\n+\t\t\tset head {}\n+\t\t}\n \t}\n \n \tif {$head eq {}} {\n-- \n1.7.12.1.382.gb0576a6\n"},{"id":"200717","messageId":"5071F340.6030206@gmail.com","threadId":"31715","inReplyTo":"1349195115-15494-1-git-send-email-andrew.kw.w@gmail.com","subject":"Re: [PATCH] git-gui: Few issues with using full path name","fromName":"Andrew Wong","fromEmail":"andrew.kw.w@gmail.com","sentAt":"2012-10-07T21:25:20Z","receivedAt":"2012-10-07T21:25:20Z","isPatch":true,"sender":{"key":"andrew.kw.w@gmail.com","avatar":"https://avatars.githubusercontent.com/u/489311?v=4"},"body":"Could we look into getting these two patches into git/git-gui?\n\nOn 10/02/12 12:25, Andrew Wong wrote:\n> I ran into a file name parsing issue in git-gui. If I'm in a subfolder and try\n> to pass a full path to \"git-gui blame\", then \"git-gui\" will fail to detect the\n> argument as a valid path. The first patch will handle this scenario.\n>\n> The second patch just another issue that I noticed when \"git-gui\" fails to\n> detect the file name. It'll then try to use the previously detected \"head\" as\n> the file name, while prepending it with \"prefix\". This is incorrect if \"head\"\n> is actually a full path.\n>\n> There is also an issue when using a full path along with a rev argument, but I\n> don't have time to look it right now. I'll try to get to that issue another\n> time.\n>\n> Andrew Wong (2):\n>   git-gui: Detect full path when parsing arguments\n>   git-gui: Don't prepend the prefix if value looks like a full path\n>\n>  git-gui.sh | 20 +++++++++++++++++---\n>  1 file changed, 17 insertions(+), 3 deletions(-)\n>\n"},{"id":"201055","messageId":"50782442.2060407@gmail.com","threadId":"31715","inReplyTo":"1349195115-15494-1-git-send-email-andrew.kw.w@gmail.com","subject":"Re: [PATCH] git-gui: Few issues with using full path name","fromName":"Andrew Wong","fromEmail":"andrew.kw.w@gmail.com","sentAt":"2012-10-12T14:08:02Z","receivedAt":"2012-10-12T14:08:02Z","isPatch":true,"sender":{"key":"andrew.kw.w@gmail.com","avatar":"https://avatars.githubusercontent.com/u/489311?v=4"},"body":"Can I get some feedback on these two patches? It'd be great to have them \nmerged into git-gui. Thanks.\n\n\nOn 10/02/2012 12:25 PM, Andrew Wong wrote:\n> I ran into a file name parsing issue in git-gui. If I'm in a subfolder and try\n> to pass a full path to \"git-gui blame\", then \"git-gui\" will fail to detect the\n> argument as a valid path. The first patch will handle this scenario.\n>\n> The second patch just another issue that I noticed when \"git-gui\" fails to\n> detect the file name. It'll then try to use the previously detected \"head\" as\n> the file name, while prepending it with \"prefix\". This is incorrect if \"head\"\n> is actually a full path.\n>\n> There is also an issue when using a full path along with a rev argument, but I\n> don't have time to look it right now. I'll try to get to that issue another\n> time.\n>\n> Andrew Wong (2):\n>    git-gui: Detect full path when parsing arguments\n>    git-gui: Don't prepend the prefix if value looks like a full path\n>\n>   git-gui.sh | 20 +++++++++++++++++---\n>   1 file changed, 17 insertions(+), 3 deletions(-)\n>\n"}]}