[PATCH] gitk: Fix "git gui blame" invocation when called from topdir
- From
Markus Heidelberg <markus.heidelberg@web.de>
- Date
- Nov 3, 2009, 23:21 UTC
- Message-ID
- <1257290501-21093-1-git-send-email-markus.heidelberg@web.de>
- In-Reply-To
- <19184.2163.760155.285153@cargo.ozlabs.ibm.com>
In this case "git rev-parse --git-dir" doesn't return an absolute path, but merely ".git", so the selected file has a relative path. The function make_relative then tries to make the already relative path relative, which results in a path like "../../../../Makefile" with as much ".." as the number of parts [pwd] consists of.
This regression was introduced by commit 9712b81 (gitk: Fix bugs in blaming code, 2008-12-06), which fixed "git gui blame" when called from subdirs.
This also fixes it for bare repositories.
Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de> ---
Paul Mackerras, 03.11.2009:
> Thanks for the patch, but I'd prefer to just add:
>
> if {[file pathtype $f] ne "relative"} {
> return $f
> }
>
> at the start of the function. I think that's easier to read than
> having a big if statement.
Definitely yes. But eq instead of ne.
gitk | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/gitk b/gitk index 32e4ab0..949abfe 100755 --- a/gitk +++ b/gitk @@ -3378,6 +3378,9 @@ proc index_sha1 {fname} { # Turn an absolute path into one relative to the current directory proc make_relative {f} { + if {[file pathtype $f] eq "relative"} { + return $f + } set elts [file split $f] set here [file split [pwd]] set ei 0
-- 1.6.5.2.155.gaa0e5