{"thread":{"id":"1349","subject":"[PATCH] gitk: Use GIT_DIR where appropriate.","startedAt":"2005-07-28T07:28:44Z","lastAt":"2005-07-28T07:28:44Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"6493","messageId":"7vpst3e6dv.fsf@assigned-by-dhcp.cox.net","threadId":"1349","inReplyTo":null,"subject":"[PATCH] gitk: Use GIT_DIR where appropriate.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-28T07:28:44Z","receivedAt":"2005-07-28T07:28:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Some places assumed .git is the GIT_DIR, resulting heads and\ntags not showing when it was run like \"GIT_DIR=. gitk --all\".\nThis is not a contrived example --- I rely on it to verify\nmy private copy of git.git repository before pushing it out.\n\nDefine a single procedure \"gitdir\" and use it.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n*** Paul, I will not be applying this to the copy Linus pulled\n*** into git.git repository, but sending it to you in a patch\n*** form.  I believe that would be easier for you to work with\n*** than pulling from git.git along with all the other stuff.\n\n gitk |   24 +++++++++++++-----------\n 1 files changed, 13 insertions(+), 11 deletions(-)\n\nc41a6a0271ea966f5d5cd648b854ec78b90096a6\ndiff --git a/gitk b/gitk\n--- a/gitk\n+++ b/gitk\n@@ -7,17 +7,22 @@ exec wish \"$0\" -- \"${1+$@}\"\n # and distributed under the terms of the GNU General Public Licence,\n # either version 2, or (at your option) any later version.\n \n+proc gitdir {} {\n+    global env\n+    if {[info exists env(GIT_DIR)]} {\n+\treturn $env(GIT_DIR)\n+    } else {\n+\treturn \".git\"\n+    }\n+}\n+\n proc getcommits {rargs} {\n     global commits commfd phase canv mainfont env\n     global startmsecs nextupdate\n     global ctext maincursor textcursor leftover\n \n     # check that we can find a .git directory somewhere...\n-    if {[info exists env(GIT_DIR)]} {\n-\tset gitdir $env(GIT_DIR)\n-    } else {\n-\tset gitdir \".git\"\n-    }\n+    set gitdir [gitdir]\n     if {![file isdirectory $gitdir]} {\n \terror_popup \"Cannot find the git directory \\\"$gitdir\\\".\"\n \texit 1\n@@ -212,7 +217,7 @@ proc parsecommit {id contents listed} {\n \n proc readrefs {} {\n     global tagids idtags headids idheads\n-    set tags [glob -nocomplain -types f .git/refs/tags/*]\n+    set tags [glob -nocomplain -types f [gitdir]/refs/tags/*]\n     foreach f $tags {\n \tcatch {\n \t    set fd [open $f r]\n@@ -241,7 +246,7 @@ proc readrefs {} {\n \t    close $fd\n \t}\n     }\n-    set heads [glob -nocomplain -types f .git/refs/heads/*]\n+    set heads [glob -nocomplain -types f [gitdir]/refs/heads/*]\n     foreach f $heads {\n \tcatch {\n \t    set fd [open $f r]\n@@ -2752,10 +2757,7 @@ proc domktag {} {\n \treturn\n     }\n     if {[catch {\n-\tset dir \".git\"\n-\tif {[info exists env(GIT_DIR)]} {\n-\t    set dir $env(GIT_DIR)\n-\t}\n+\tset dir [gitdir]\n \tset fname [file join $dir \"refs/tags\" $tag]\n \tset f [open $fname w]\n \tputs $f $id\n"}]}