All of lore.kernel.org
 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; 4+ 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] 4+ messages in thread

* Re: [PATCH resend] gitk: Fix "git gui blame" invocation when called from topdir
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Mackerras @ 2009-11-03 10:39 UTC (permalink / raw)
  To: Markus Heidelberg; +Cc: git

Markus Heidelberg writes:

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

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.  Would you like to do a new patch or will I
just make that change to your patch?

Paul.

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

* [PATCH] gitk: Fix "git gui blame" invocation when called from topdir
  2009-11-03 10:39 ` Paul Mackerras
@ 2009-11-03 23:21   ` Markus Heidelberg
  2009-11-14 11:14     ` Paul Mackerras
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Heidelberg @ 2009-11-03 23:21 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>
---

    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

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

* Re: [PATCH] gitk: Fix "git gui blame" invocation when called from topdir
  2009-11-03 23:21   ` [PATCH] " Markus Heidelberg
@ 2009-11-14 11:14     ` Paul Mackerras
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Mackerras @ 2009-11-14 11:14 UTC (permalink / raw)
  To: Markus Heidelberg; +Cc: git

Markus Heidelberg writes:

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

Thanks, applied.

Paul.

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

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

Thread overview: 4+ 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.