Skip to content

Commit 86e847b

Browse files
Martin von Zweigbergkpaulusmack
authored andcommitted
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 <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent da616db commit 86e847b

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

gitk

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ exec wish "$0" -- "$@"
99

1010
package require Tk
1111

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-
2112
# A simple scheduler for compute-intensive stuff.
2213
# The aim is to make sure that event handlers for GUI actions can
2314
# run at least every 50-100 ms. Unfortunately fileevent handlers are
@@ -11523,14 +11514,10 @@ setui $uicolor
1152311514
setoptions
1152411515

1152511516
# 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]}]} {
1152711518
show_error {} . [mc "Cannot find a git repository here."]
1152811519
exit 1
1152911520
}
11530-
if {![file isdirectory $gitdir]} {
11531-
show_error {} . [mc "Cannot find the git directory \"%s\"." $gitdir]
11532-
exit 1
11533-
}
1153411521

1153511522
set selecthead {}
1153611523
set selectheadid {}

0 commit comments

Comments
 (0)