git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Paul Mackerras <paulus@samba.org>
Cc: git@vger.kernel.org
Subject: [PATCH] gitk: Use GIT_DIR where appropriate.
Date: Thu, 28 Jul 2005 00:28:44 -0700	[thread overview]
Message-ID: <7vpst3e6dv.fsf@assigned-by-dhcp.cox.net> (raw)

Some places assumed .git is the GIT_DIR, resulting heads and
tags not showing when it was run like "GIT_DIR=. gitk --all".
This is not a contrived example --- I rely on it to verify
my private copy of git.git repository before pushing it out.

Define a single procedure "gitdir" and use it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

*** Paul, I will not be applying this to the copy Linus pulled
*** into git.git repository, but sending it to you in a patch
*** form.  I believe that would be easier for you to work with
*** than pulling from git.git along with all the other stuff.

 gitk |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

c41a6a0271ea966f5d5cd648b854ec78b90096a6
diff --git a/gitk b/gitk
--- a/gitk
+++ b/gitk
@@ -7,17 +7,22 @@ exec wish "$0" -- "${1+$@}"
 # and distributed under the terms of the GNU General Public Licence,
 # either version 2, or (at your option) any later version.
 
+proc gitdir {} {
+    global env
+    if {[info exists env(GIT_DIR)]} {
+	return $env(GIT_DIR)
+    } else {
+	return ".git"
+    }
+}
+
 proc getcommits {rargs} {
     global commits commfd phase canv mainfont env
     global startmsecs nextupdate
     global ctext maincursor textcursor leftover
 
     # check that we can find a .git directory somewhere...
-    if {[info exists env(GIT_DIR)]} {
-	set gitdir $env(GIT_DIR)
-    } else {
-	set gitdir ".git"
-    }
+    set gitdir [gitdir]
     if {![file isdirectory $gitdir]} {
 	error_popup "Cannot find the git directory \"$gitdir\"."
 	exit 1
@@ -212,7 +217,7 @@ proc parsecommit {id contents listed} {
 
 proc readrefs {} {
     global tagids idtags headids idheads
-    set tags [glob -nocomplain -types f .git/refs/tags/*]
+    set tags [glob -nocomplain -types f [gitdir]/refs/tags/*]
     foreach f $tags {
 	catch {
 	    set fd [open $f r]
@@ -241,7 +246,7 @@ proc readrefs {} {
 	    close $fd
 	}
     }
-    set heads [glob -nocomplain -types f .git/refs/heads/*]
+    set heads [glob -nocomplain -types f [gitdir]/refs/heads/*]
     foreach f $heads {
 	catch {
 	    set fd [open $f r]
@@ -2752,10 +2757,7 @@ proc domktag {} {
 	return
     }
     if {[catch {
-	set dir ".git"
-	if {[info exists env(GIT_DIR)]} {
-	    set dir $env(GIT_DIR)
-	}
+	set dir [gitdir]
 	set fname [file join $dir "refs/tags" $tag]
 	set f [open $fname w]
 	puts $f $id

                 reply	other threads:[~2005-07-28  7:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vpst3e6dv.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).