gitk: Simplify calculation of gitdir

Since 5024baa ([PATCH] Make gitk work when launched in a subdirectory, 2007-01-09), gitk has used 'git rev-parse --git-dir' to find the .git directory. However, gitk still first checks for the $GIT_DIR environment variable and that the value returned from git-rev-parse does not point to a file. Since git-rev-parse does both of these checks already, the checks can safely be removed from gitk. This makes the gitdir procedure small enough to inline. This cleanup introduces a UI regression in that the error message will now be "Cannot find a git repository here." even in the case where GIT_DIR points to a file, for which the error message was previously "Cannot find the git directory \"%s\".". It should be noted, though, that even before this patch, 'gitk --git-dir=path/to/some/file' would give the former error message. Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>

Martin von Zweigbergk committed Apr 4, 2011 at 22:14 UTC 86e847bcbf2b7f8700bcb3f3eaf7d08801e0cbab
1 file changed +1 -14
gitk
+1 -14
@@ -9,15 +9,6 @@ exec wish "$0" -- "$@"
9
10 package require Tk
11
12 -proc gitdir {} {
13 - global env
14 - if {[info exists env(GIT_DIR)]} {
15 - return $env(GIT_DIR)
16 - } else {
17 - return [exec git rev-parse --git-dir]
18 - }
19 -}
20 -
12 # A simple scheduler for compute-intensive stuff.
13 # The aim is to make sure that event handlers for GUI actions can
14 # run at least every 50-100 ms. Unfortunately fileevent handlers are
@@ -11523,14 +11514,10 @@ setui $uicolor
11514 setoptions
11515
11516 # check that we can find a .git directory somewhere...
11526 -if {[catch {set gitdir [gitdir]}]} {
11517 +if {[catch {set gitdir [exec git rev-parse --git-dir]}]} {
11518 show_error {} . [mc "Cannot find a git repository here."]
11519 exit 1
11520 }
11530 -if {![file isdirectory $gitdir]} {
11531 - show_error {} . [mc "Cannot find the git directory \"%s\"." $gitdir]
11532 - exit 1
11533 -}
11521
11522 set selecthead {}
11523 set selectheadid {}