Skip to content

Commit c612785

Browse files
committed
git-gui: Use prefix if blame is run in a subdirectory
I think it was Andy Parkins who pointed out that git gui blame HEAD f does not work if f is in a subdirectory and we are currently running git-gui within that subdirectory. This is happening because we did not take the user's prefix into account when we computed the file path in the repository. We now assume the prefix as returned by rev-parse --show-prefix is valid and we use that during the command line blame subcommand when we apply the parameters. Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 685caf9 commit c612785

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

git-gui.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,14 @@ unset -nocomplain v _junk act_maj act_min req_maj req_min
261261
##
262262
## repository setup
263263

264-
if { [catch {set _gitdir $env(GIT_DIR)}]
265-
&& [catch {set _gitdir [git rev-parse --git-dir]} err]} {
264+
if {[catch {
265+
set _gitdir $env(GIT_DIR)
266+
set _prefix {}
267+
}]
268+
&& [catch {
269+
set _gitdir [git rev-parse --git-dir]
270+
set _prefix [git rev-parse --show-prefix]
271+
} err]} {
266272
catch {wm withdraw .}
267273
error_popup "Cannot find the git directory:\n\n$err"
268274
exit 1
@@ -1590,7 +1596,7 @@ blame {
15901596
exit 1
15911597
}
15921598
set current_branch [lindex $argv 0]
1593-
blame::new $current_branch [lindex $argv 1]
1599+
blame::new $current_branch $_prefix[lindex $argv 1]
15941600
return
15951601
}
15961602
citool -

0 commit comments

Comments
 (0)