summaryrefslogtreecommitdiff
path: root/git-gui.sh
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-07-09 01:19:59 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2007-07-09 02:34:51 (GMT)
commit02087abccea681bc0e1f6a9607e97df79ebbf2d9 (patch)
treead466fc8d68d0fd3eb3d152a25cfdec3ccef60d2 /git-gui.sh
parentd41b43eb4c73044d0fff2057211fc78e4e7b2094 (diff)
downloadgit-02087abccea681bc0e1f6a9607e97df79ebbf2d9.zip
git-02087abccea681bc0e1f6a9607e97df79ebbf2d9.tar.gz
git-02087abccea681bc0e1f6a9607e97df79ebbf2d9.tar.bz2
git-gui: Unabbreviate commit SHA-1s prior to display
If the end-user feeds us an abbreviated SHA-1 on the command line for `git gui browser` or `git gui blame` we now unabbreviate the value through `git rev-parse` so that the title section of the blame or browser window shows the user the complete SHA-1 as Git determined it to be. If the abbreviated value was ambiguous we now complain with the standard error message(s) as reported by git-rev-parse --verify, so that the user can understand what might be wrong and correct their command line. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'git-gui.sh')
-rwxr-xr-xgit-gui.sh21
1 files changed, 20 insertions, 1 deletions
diff --git a/git-gui.sh b/git-gui.sh
index ac04367..1844c90 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1746,7 +1746,18 @@ browser {
set subcommand_args {rev?}
switch [llength $argv] {
0 { load_current_branch }
- 1 { set current_branch [lindex $argv 0] }
+ 1 {
+ set current_branch [lindex $argv 0]
+ if {[regexp {^[0-9a-f]{1,39}$} $current_branch]} {
+ if {[catch {
+ set current_branch \
+ [git rev-parse --verify $current_branch]
+ } err]} {
+ puts stderr $err
+ exit 1
+ }
+ }
+ }
default usage
}
browser::new $current_branch
@@ -1781,6 +1792,14 @@ blame {
if {$head eq {}} {
load_current_branch
} else {
+ if {[regexp {^[0-9a-f]{1,39}$} $head]} {
+ if {[catch {
+ set head [git rev-parse --verify $head]
+ } err]} {
+ puts stderr $err
+ exit 1
+ }
+ }
set current_branch $head
}