git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH resend] gitk: Fix "git gui blame" invocation when called from topdir
@ 2009-10-31 12:09 Markus Heidelberg
  2009-11-03 10:39 ` Paul Mackerras
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Heidelberg @ 2009-10-31 12:09 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: git, Markus Heidelberg

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>
---
 gitk |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/gitk b/gitk
index a0214b7..07a9440 100755
--- a/gitk
+++ b/gitk
@@ -3377,21 +3377,25 @@ proc index_sha1 {fname} {
 
 # Turn an absolute path into one relative to the current directory
 proc make_relative {f} {
-    set elts [file split $f]
-    set here [file split [pwd]]
-    set ei 0
-    set hi 0
-    set res {}
-    foreach d $here {
-	if {$ei < $hi || $ei >= [llength $elts] || [lindex $elts $ei] ne $d} {
-	    lappend res ".."
-	} else {
-	    incr ei
+    if {[file pathtype $f] ne "relative"} {
+	set elts [file split $f]
+	set here [file split [pwd]]
+	set ei 0
+	set hi 0
+	set res {}
+	foreach d $here {
+	    if {$ei < $hi || $ei >= [llength $elts] || [lindex $elts $ei] ne $d} {
+		lappend res ".."
+	    } else {
+		incr ei
+	    }
+	    incr hi
 	}
-	incr hi
+	set elts [concat $res [lrange $elts $ei end]]
+	return [eval file join $elts]
+    } else {
+	return $f
     }
-    set elts [concat $res [lrange $elts $ei end]]
-    return [eval file join $elts]
 }
 
 proc external_blame {parent_idx {line {}}} {
-- 
1.6.5.2.155.gaa0e5

^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] gitk: Fix "git gui blame" invocation when called from topdir
@ 2009-06-21 17:34 Markus Heidelberg
  0 siblings, 0 replies; 5+ messages in thread
From: Markus Heidelberg @ 2009-06-21 17:34 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: git, Markus Heidelberg

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>
---

    For convencience the output of diff -w:

    @@ -3366,6 +3366,7 @@ proc index_sha1 {fname} {
    
     # Turn an absolute path into one relative to the current directory
     proc make_relative {f} {
    +    if {[file pathtype $f] ne "relative"} {
         set elts [file split $f]
         set here [file split [pwd]]
         set ei 0
    @@ -3381,6 +3382,9 @@ proc make_relative {f} {
         }
         set elts [concat $res [lrange $elts $ei end]]
         return [eval file join $elts]
    +    } else {
    +       return $f
    +    }
     }
    
     proc external_blame {parent_idx {line {}}} {


    While fixing this I also noticed that the tree view treats pwd as the
    topdir, so it shows directly .gitignore instead of po/.gitignore for
    example.

 gitk |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/gitk b/gitk
index 4604c83..46d7782 100755
--- a/gitk
+++ b/gitk
@@ -3366,21 +3366,25 @@ proc index_sha1 {fname} {
 
 # Turn an absolute path into one relative to the current directory
 proc make_relative {f} {
-    set elts [file split $f]
-    set here [file split [pwd]]
-    set ei 0
-    set hi 0
-    set res {}
-    foreach d $here {
-	if {$ei < $hi || $ei >= [llength $elts] || [lindex $elts $ei] ne $d} {
-	    lappend res ".."
-	} else {
-	    incr ei
+    if {[file pathtype $f] ne "relative"} {
+	set elts [file split $f]
+	set here [file split [pwd]]
+	set ei 0
+	set hi 0
+	set res {}
+	foreach d $here {
+	    if {$ei < $hi || $ei >= [llength $elts] || [lindex $elts $ei] ne $d} {
+		lappend res ".."
+	    } else {
+		incr ei
+	    }
+	    incr hi
 	}
-	incr hi
+	set elts [concat $res [lrange $elts $ei end]]
+	return [eval file join $elts]
+    } else {
+	return $f
     }
-    set elts [concat $res [lrange $elts $ei end]]
-    return [eval file join $elts]
 }
 
 proc external_blame {parent_idx {line {}}} {
-- 
1.6.3.2.369.gdf06

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-11-14 11:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-31 12:09 [PATCH resend] gitk: Fix "git gui blame" invocation when called from topdir Markus Heidelberg
2009-11-03 10:39 ` Paul Mackerras
2009-11-03 23:21   ` [PATCH] " Markus Heidelberg
2009-11-14 11:14     ` Paul Mackerras
  -- strict thread matches above, loose matches on Subject: below --
2009-06-21 17:34 Markus Heidelberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).