Skip to content

Commit 2f38dd0

Browse files
johnkeepingpatthoyts
authored andcommitted
git-gui: fix file name handling with non-empty prefix
Commit e3d06ca (git-gui: Detect full path when parsing arguments - 2012-10-02) fixed the handling of absolute paths passed to the browser and blame subcommands by checking whether the file exists without the prefix before prepending the prefix and checking again. Since we have chdir'd to the top level of the working tree before doing this, this does not work if a file with the same name exists in a subdirectory and at the top level (for example Makefile in git.git's t/ directory). Instead of doing this, revert that patch and fix absolute path issue by using "file join" to prepend the prefix to the supplied path. This will correctly handle absolute paths by skipping the prefix in that case. Acked-by: Andrew Wong <[email protected]> Signed-off-by: John Keeping <[email protected]> Signed-off-by: Pat Thoyts <[email protected]>
1 parent 7d2017e commit 2f38dd0

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

git-gui.sh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,19 +3017,11 @@ blame {
30173017
set jump_spec {}
30183018
set is_path 0
30193019
foreach a $argv {
3020-
if {[file exists $a]} {
3021-
if {$path ne {}} usage
3022-
set path [normalize_relpath $a]
3023-
break
3024-
} elseif {[file exists $_prefix$a]} {
3025-
if {$path ne {}} usage
3026-
set path [normalize_relpath $_prefix$a]
3027-
break
3028-
}
3020+
set p [file join $_prefix $a]
30293021
3030-
if {$is_path} {
3022+
if {$is_path || [file exists $p]} {
30313023
if {$path ne {}} usage
3032-
set path [normalize_relpath $_prefix$a]
3024+
set path [normalize_relpath $p]
30333025
break
30343026
} elseif {$a eq {--}} {
30353027
if {$path ne {}} {

0 commit comments

Comments
 (0)