git-gui: Few issues with using full path name
PATCH 1/1 git-gui: Few issues with using full path name
I ran into a file name parsing issue in git-gui. If I'm in a subfolder and try to pass a full path to "git-gui blame", then "git-gui" will fail to detect the argument as a valid path. The first patch will handle this scenario.
The second patch just another issue that I noticed when "git-gui" fails to detect the file name. It'll then try to use the previously detected "head" as the file name, while prepending it with "prefix". This is incorrect if "head" is actually a full path.
There is also an issue when using a full path along with a rev argument, but I don't have time to look it right now. I'll try to get to that issue another time.
Andrew Wong (2):
git-gui: Detect full path when parsing arguments
git-gui: Don't prepend the prefix if value looks like a full path
git-gui.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.12.1.382.gb0576a6
PATCH 1/2 git-gui: Detect full path when parsing arguments
When running "git-gui blame" from a subfolder (which means prefix is non-empty), if we pass a full path as argument, the argument parsing will fail to recognize the argument as a file name, because prefix is prepended to the argument.
This patch handles that scenario by adding an additional branch that checks the file name without using the prefix.
--- git-gui.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
git-gui.sh +10 -1
@@ -3003,10 +3003,19 @@ blame { set jump_spec {} set is_path 0 foreach a $argv { - if {$is_path || [file exists $_prefix$a]} { + if {[file exists $a]} { + if {$path ne {}} usage + set path [normalize_relpath $a] + break + } elseif {[file exists $_prefix$a]} { if {$path ne {}} usage set path [normalize_relpath $_prefix$a] break + } + + if {$is_path} { + if {$path ne {}} usage + break } elseif {$a eq {--}} { if {$path ne {}} { if {$head ne {}} usage
Signature · 1 line
1.7.12.1.382.gb0576a6
PATCH 2/2 git-gui: Don't prepend the prefix if value looks like a full path
In reply to Andrew WongWhen argument parsing fails to detect a file name, "git-gui" will try to use the previously detected "head" as the file name. We should avoid prepending the prefix if "head" looks like a full path.
--- git-gui.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
git-gui.sh +7 -2
@@ -3037,8 +3037,13 @@ blame { unset is_path if {$head ne {} && $path eq {}} { - set path [normalize_relpath $_prefix$head] - set head {} + if {[string index $head 0] eq {/}} { + set path [normalize_relpath $head] + set head {} + } else { + set path [normalize_relpath $_prefix$head] + set head {} + } } if {$head eq {}} {
Signature · 1 line
1.7.12.1.382.gb0576a6
Could we look into getting these two patches into git/git-gui?
Quoted 20 lines · Andrew Wong
I ran into a file name parsing issue in git-gui. If I'm in a subfolder and try to pass a full path to "git-gui blame", then "git-gui" will fail to detect the argument as a valid path. The first patch will handle this scenario.
The second patch just another issue that I noticed when "git-gui" fails to detect the file name. It'll then try to use the previously detected "head" as the file name, while prepending it with "prefix". This is incorrect if "head" is actually a full path.
There is also an issue when using a full path along with a rev argument, but I don't have time to look it right now. I'll try to get to that issue another time.
Andrew Wong (2):
git-gui: Detect full path when parsing arguments
git-gui: Don't prepend the prefix if value looks like a full pathgit-gui.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Can I get some feedback on these two patches? It'd be great to have them merged into git-gui. Thanks.
Quoted 20 lines · Andrew Wong
I ran into a file name parsing issue in git-gui. If I'm in a subfolder and try to pass a full path to "git-gui blame", then "git-gui" will fail to detect the argument as a valid path. The first patch will handle this scenario.
The second patch just another issue that I noticed when "git-gui" fails to detect the file name. It'll then try to use the previously detected "head" as the file name, while prepending it with "prefix". This is incorrect if "head" is actually a full path.
There is also an issue when using a full path along with a rev argument, but I don't have time to look it right now. I'll try to get to that issue another time.
Andrew Wong (2):
git-gui: Detect full path when parsing arguments
git-gui: Don't prepend the prefix if value looks like a full pathgit-gui.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)