git-gui: Cache the GIT_COMMITTER_IDENT value on first sign-off.
[gitweb.git] / git-gui
diff --git a/git-gui b/git-gui
index d405008d2c7f85598f6d6dcac4c978a6906a1f7c..ad3aa0727c55a8e62609cec658108e7ecf3dedd6 100755 (executable)
--- a/git-gui
+++ b/git-gui
@@ -14,7 +14,7 @@ exec wish "$0" -- "$@"
 set single_commit 0
 set status_active 0
 set diff_active 0
-set checkin_active 0
+set update_active 0
 set commit_active 0
 set update_index_fd {}
 
@@ -469,7 +469,7 @@ before committing.
                        error_popup "Unmerged files cannot be committed.
 
 File $path has merge conflicts.
-You must resolve them and check the file in before committing.
+You must resolve them and include the file before committing.
 "
                        unlock_index
                        return
@@ -483,9 +483,9 @@ File $path cannot be committed by this program.
                }
        }
        if {!$files_ready} {
-               error_popup {No checked-in files to commit.
+               error_popup {No included files to commit.
 
-You must check-in at least 1 file before you can commit.
+You must include at least 1 file before you can commit.
 }
                unlock_index
                return
@@ -626,7 +626,7 @@ proc commit_stage2 {fd_wt curHEAD msg} {
        set HEAD $cmt_id
        set PARENT $cmt_id
        unlock_index
-       update_status "Changes committed as $cmt_id."
+       update_status "Changes committed as [string range $cmt_id 0 7]."
 }
 
 ######################################################################
@@ -819,7 +819,7 @@ proc display_file {path state} {
                $new_w image create $lno.0 \
                        -align center -padx 5 -pady 1 \
                        -name [lindex $s 1] \
-                       -image [mapicon $m $path]
+                       -image $new_icon
                $new_w insert $lno.1 "$path\n"
                $new_w conf -state disabled
        } elseif {$new_icon != [mapicon $old_m $path]} {
@@ -1088,7 +1088,7 @@ foreach i {
                {__ i plain    "Unmodified"}
                {_M i mod      "Modified"}
                {M_ i fulltick "Checked in"}
-               {MM i parttick "Partially checked in"}
+               {MM i parttick "Partially included"}
 
                {_O o plain    "Untracked"}
                {A_ o fulltick "Added"}
@@ -1373,13 +1373,13 @@ proc do_rescan {} {
        update_status
 }
 
-proc do_checkin_all {} {
-       global checkin_active ui_status_value
+proc do_include_all {} {
+       global update_active ui_status_value
 
-       if {$checkin_active || ![lock_index begin-update]} return
+       if {$update_active || ![lock_index begin-update]} return
 
-       set checkin_active 1
-       set ui_status_value {Checking in all files...}
+       set update_active 1
+       set ui_status_value {Including all modified files...}
        after 1 {
                with_update_index {
                        foreach path [array names file_states] {
@@ -1393,25 +1393,34 @@ proc do_checkin_all {} {
                                }
                        }
                }
-               set checkin_active 0
+               set update_active 0
                set ui_status_value {Ready.}
        }
 }
 
+set GIT_COMMITTER_IDENT {}
+
 proc do_signoff {} {
-       global ui_comm
+       global ui_comm GIT_COMMITTER_IDENT
 
-       catch {
-               set me [exec git var GIT_COMMITTER_IDENT]
-               if {[regexp {(.*) [0-9]+ [-+0-9]+$} $me me name]} {
-                       set str "Signed-off-by: $name"
-                       if {[$ui_comm get {end -1c linestart} {end -1c}] != $str} {
-                               $ui_comm insert end "\n"
-                               $ui_comm insert end $str
-                               $ui_comm see end
-                       }
+       if {$GIT_COMMITTER_IDENT == {}} {
+               if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
+                       error_popup "Unable to obtain your identity:\n$err"
+                       return
+               }
+               if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
+                       $me me GIT_COMMITTER_IDENT]} {
+                       error_popup "Invalid GIT_COMMITTER_IDENT:\n$me"
+                       return
                }
        }
+
+       set str "Signed-off-by: $GIT_COMMITTER_IDENT"
+       if {[$ui_comm get {end -1c linestart} {end -1c}] != $str} {
+               $ui_comm insert end "\n"
+               $ui_comm insert end $str
+               $ui_comm see end
+       }
 }
 
 proc do_amend_last {} {
@@ -1503,8 +1512,8 @@ lappend disable_on_lock \
        -font $mainfont
 lappend disable_on_lock \
        [list .mbar.commit entryconf [.mbar.commit index last] -state]
-.mbar.commit add command -label {Check-in All Files} \
-       -command do_checkin_all \
+.mbar.commit add command -label {Include All Files} \
+       -command do_include_all \
        -accelerator $M1T-U \
        -font $mainfont
 lappend disable_on_lock \
@@ -1608,11 +1617,11 @@ button .vpane.lower.commarea.buttons.amend -text {Amend Last} \
 pack .vpane.lower.commarea.buttons.amend -side top -fill x
 lappend disable_on_lock {.vpane.lower.commarea.buttons.amend conf -state}
 
-button .vpane.lower.commarea.buttons.ciall -text {Check-in All} \
-       -command do_checkin_all \
+button .vpane.lower.commarea.buttons.incall -text {Include All} \
+       -command do_include_all \
        -font $mainfont
-pack .vpane.lower.commarea.buttons.ciall -side top -fill x
-lappend disable_on_lock {.vpane.lower.commarea.buttons.ciall conf -state}
+pack .vpane.lower.commarea.buttons.incall -side top -fill x
+lappend disable_on_lock {.vpane.lower.commarea.buttons.incall conf -state}
 
 button .vpane.lower.commarea.buttons.signoff -text {Sign Off} \
        -command do_signoff \
@@ -1723,8 +1732,8 @@ bind all <$M1B-Key-r> do_rescan
 bind all <$M1B-Key-R> do_rescan
 bind .   <$M1B-Key-s> do_signoff
 bind .   <$M1B-Key-S> do_signoff
-bind .   <$M1B-Key-u> do_checkin_all
-bind .   <$M1B-Key-U> do_checkin_all
+bind .   <$M1B-Key-u> do_include_all
+bind .   <$M1B-Key-U> do_include_all
 bind .   <$M1B-Key-Return> do_commit
 bind all <$M1B-Key-q> do_quit
 bind all <$M1B-Key-Q> do_quit