summaryrefslogtreecommitdiff
path: root/git-gui.sh
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2007-07-17 23:58:56 -0400
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2007-07-17 23:58:56 -0400
commitc52c94524bdf9bbe515137b7f3f0240bc10a7f63 (patch)
treee2606a9949f40667571e32f3d6aed87cec7d1539 /git-gui.sh
parentgit-gui: Move feature option selection before GIT_DIR init (diff)
downloadtgif-c52c94524bdf9bbe515137b7f3f0240bc10a7f63.tar.xz
git-gui: Allow blame/browser subcommands on bare repositories
A long time ago Linus Torvalds tried to run git-gui on a bare repository to look at the blame viewer, but it failed to start because we required that the user run us only from within a working directory that had a normal git repository associated with it. This change relaxes that requirement so that you can start the tree browser or the blame viewer against a bare repository. In the latter case we do require that you provide a revision and a pathname if we cannot find the pathname in the current working directory. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'git-gui.sh')
-rwxr-xr-xgit-gui.sh45
1 files changed, 32 insertions, 13 deletions
diff --git a/git-gui.sh b/git-gui.sh
index f13fa80b46..9ddb61ea90 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -650,10 +650,13 @@ if {$subcommand eq {gui} && [llength $argv] > 0} {
enable_option multicommit
enable_option branch
enable_option transport
+disable_option bare
switch -- $subcommand {
browser -
blame {
+ enable_option bare
+
disable_option multicommit
disable_option branch
disable_option transport
@@ -691,19 +694,24 @@ if {![file isdirectory $_gitdir]} {
error_popup "Git directory not found:\n\n$_gitdir"
exit 1
}
-if {[lindex [file split $_gitdir] end] ne {.git}} {
- catch {wm withdraw .}
- error_popup "Cannot use funny .git directory:\n\n$_gitdir"
- exit 1
+if {![is_enabled bare]} {
+ if {[lindex [file split $_gitdir] end] ne {.git}} {
+ catch {wm withdraw .}
+ error_popup "Cannot use funny .git directory:\n\n$_gitdir"
+ exit 1
+ }
+ if {[catch {cd [file dirname $_gitdir]} err]} {
+ catch {wm withdraw .}
+ error_popup "No working directory [file dirname $_gitdir]:\n\n$err"
+ exit 1
+ }
}
-if {[catch {cd [file dirname $_gitdir]} err]} {
- catch {wm withdraw .}
- error_popup "No working directory [file dirname $_gitdir]:\n\n$err"
- exit 1
+set _reponame [file split [file normalize $_gitdir]]
+if {[lindex $_reponame end] eq {.git}} {
+ set _reponame [lindex $_reponame end-1]
+} else {
+ set _reponame [lindex $_reponame end]
}
-set _reponame [lindex [file split \
- [file normalize [file dirname $_gitdir]]] \
- end]
######################################################################
##
@@ -1990,7 +1998,8 @@ browser {
return
}
blame {
- set subcommand_args {rev? path?}
+ set subcommand_args {rev? path}
+ if {$argv eq {}} usage
set head {}
set path {}
set is_path 0
@@ -2009,12 +2018,18 @@ blame {
} elseif {$head eq {}} {
if {$head ne {}} usage
set head $a
+ set is_path 1
} else {
usage
}
}
unset is_path
+ if {$head ne {} && $path eq {}} {
+ set path $_prefix$head
+ set head {}
+ }
+
if {$head eq {}} {
load_current_branch
} else {
@@ -2029,7 +2044,11 @@ blame {
set current_branch $head
}
- if {$path eq {}} usage
+ if {$head eq {} && ![file exists $path]} {
+ puts stderr "fatal: cannot stat path $path: No such file or directory"
+ exit 1
+ }
+
blame::new $head $path
return
}