{"thread":{"id":"21445","subject":"[PATCH resend] gitk: Fix \"git gui blame\" invocation when called from topdir","startedAt":"2009-10-31T12:09:34Z","lastAt":"2009-11-14T11:14:17Z","messageCount":4,"participants":["Markus Heidelberg","Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"126522","messageId":"1256990974-32671-1-git-send-email-markus.heidelberg@web.de","threadId":"21445","inReplyTo":null,"subject":"[PATCH resend] gitk: Fix \"git gui blame\" invocation when called from topdir","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-10-31T12:09:34Z","receivedAt":"2009-10-31T12:09:34Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"In this case \"git rev-parse --git-dir\" doesn't return an absolute path,\nbut merely \".git\", so the selected file has a relative path.\nThe function make_relative then tries to make the already relative path\nrelative, which results in a path like \"../../../../Makefile\" with as\nmuch \"..\" as the number of parts [pwd] consists of.\n\nThis regression was introduced by commit 9712b81 (gitk: Fix bugs in\nblaming code, 2008-12-06), which fixed \"git gui blame\" when called from\nsubdirs.\n\nThis also fixes it for bare repositories.\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n gitk |   30 +++++++++++++++++-------------\n 1 files changed, 17 insertions(+), 13 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex a0214b7..07a9440 100755\n--- a/gitk\n+++ b/gitk\n@@ -3377,21 +3377,25 @@ proc index_sha1 {fname} {\n \n # Turn an absolute path into one relative to the current directory\n proc make_relative {f} {\n-    set elts [file split $f]\n-    set here [file split [pwd]]\n-    set ei 0\n-    set hi 0\n-    set res {}\n-    foreach d $here {\n-\tif {$ei < $hi || $ei >= [llength $elts] || [lindex $elts $ei] ne $d} {\n-\t    lappend res \"..\"\n-\t} else {\n-\t    incr ei\n+    if {[file pathtype $f] ne \"relative\"} {\n+\tset elts [file split $f]\n+\tset here [file split [pwd]]\n+\tset ei 0\n+\tset hi 0\n+\tset res {}\n+\tforeach d $here {\n+\t    if {$ei < $hi || $ei >= [llength $elts] || [lindex $elts $ei] ne $d} {\n+\t\tlappend res \"..\"\n+\t    } else {\n+\t\tincr ei\n+\t    }\n+\t    incr hi\n \t}\n-\tincr hi\n+\tset elts [concat $res [lrange $elts $ei end]]\n+\treturn [eval file join $elts]\n+    } else {\n+\treturn $f\n     }\n-    set elts [concat $res [lrange $elts $ei end]]\n-    return [eval file join $elts]\n }\n \n proc external_blame {parent_idx {line {}}} {\n-- \n1.6.5.2.155.gaa0e5\n"},{"id":"126641","messageId":"19184.2163.760155.285153@cargo.ozlabs.ibm.com","threadId":"21445","inReplyTo":"1256990974-32671-1-git-send-email-markus.heidelberg@web.de","subject":"Re: [PATCH resend] gitk: Fix \"git gui blame\" invocation when called from topdir","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2009-11-03T10:39:47Z","receivedAt":"2009-11-03T10:39:47Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Markus Heidelberg writes:\n\n> In this case \"git rev-parse --git-dir\" doesn't return an absolute path,\n> but merely \".git\", so the selected file has a relative path.\n> The function make_relative then tries to make the already relative path\n> relative, which results in a path like \"../../../../Makefile\" with as\n> much \"..\" as the number of parts [pwd] consists of.\n> \n> This regression was introduced by commit 9712b81 (gitk: Fix bugs in\n> blaming code, 2008-12-06), which fixed \"git gui blame\" when called from\n> subdirs.\n> \n> This also fixes it for bare repositories.\n\nThanks for the patch, but I'd prefer to just add:\n\n    if {[file pathtype $f] ne \"relative\"} {\n\treturn $f\n    }\n\nat the start of the function.  I think that's easier to read than\nhaving a big if statement.  Would you like to do a new patch or will I\njust make that change to your patch?\n\nPaul.\n"},{"id":"126687","messageId":"1257290501-21093-1-git-send-email-markus.heidelberg@web.de","threadId":"21445","inReplyTo":"19184.2163.760155.285153@cargo.ozlabs.ibm.com","subject":"[PATCH] gitk: Fix \"git gui blame\" invocation when called from topdir","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-11-03T23:21:41Z","receivedAt":"2009-11-03T23:21:41Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"In this case \"git rev-parse --git-dir\" doesn't return an absolute path,\nbut merely \".git\", so the selected file has a relative path.\nThe function make_relative then tries to make the already relative path\nrelative, which results in a path like \"../../../../Makefile\" with as\nmuch \"..\" as the number of parts [pwd] consists of.\n\nThis regression was introduced by commit 9712b81 (gitk: Fix bugs in\nblaming code, 2008-12-06), which fixed \"git gui blame\" when called from\nsubdirs.\n\nThis also fixes it for bare repositories.\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n\n    Paul Mackerras, 03.11.2009:\n    > Thanks for the patch, but I'd prefer to just add:\n    > \n    >     if {[file pathtype $f] ne \"relative\"} {\n    >         return $f\n    >     }\n    > \n    > at the start of the function.  I think that's easier to read than\n    > having a big if statement.\n    \n    Definitely yes. But eq instead of ne.\n    \n\n gitk |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 32e4ab0..949abfe 100755\n--- a/gitk\n+++ b/gitk\n@@ -3378,6 +3378,9 @@ proc index_sha1 {fname} {\n \n # Turn an absolute path into one relative to the current directory\n proc make_relative {f} {\n+    if {[file pathtype $f] eq \"relative\"} {\n+\treturn $f\n+    }\n     set elts [file split $f]\n     set here [file split [pwd]]\n     set ei 0\n-- \n1.6.5.2.155.gaa0e5\n"},{"id":"127545","messageId":"19198.37129.682215.327167@cargo.ozlabs.ibm.com","threadId":"21445","inReplyTo":"1257290501-21093-1-git-send-email-markus.heidelberg@web.de","subject":"Re: [PATCH] gitk: Fix \"git gui blame\" invocation when called from topdir","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2009-11-14T11:14:17Z","receivedAt":"2009-11-14T11:14:17Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Markus Heidelberg writes:\n\n> In this case \"git rev-parse --git-dir\" doesn't return an absolute path,\n> but merely \".git\", so the selected file has a relative path.\n> The function make_relative then tries to make the already relative path\n> relative, which results in a path like \"../../../../Makefile\" with as\n> much \"..\" as the number of parts [pwd] consists of.\n> \n> This regression was introduced by commit 9712b81 (gitk: Fix bugs in\n> blaming code, 2008-12-06), which fixed \"git gui blame\" when called from\n> subdirs.\n> \n> This also fixes it for bare repositories.\n> \n> Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n\nThanks, applied.\n\nPaul.\n"}]}