git-gui: Cache the GIT_COMMITTER_IDENT value on first sign-off.

Caching the Signed-Off-By line isn't very important (as its not
performance critical).  The major improvement here is that we
now report an error to the user if we can't obtain their name
from git-var.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2006-11-08 23:05:46 -05:00
parent d4ab2035ca
commit 97bf01c465

31
git-gui
View File

@ -1398,19 +1398,28 @@ proc do_include_all {} {
} }
} }
proc do_signoff {} { set GIT_COMMITTER_IDENT {}
global ui_comm
catch { proc do_signoff {} {
set me [exec git var GIT_COMMITTER_IDENT] global ui_comm GIT_COMMITTER_IDENT
if {[regexp {(.*) [0-9]+ [-+0-9]+$} $me me name]} {
set str "Signed-off-by: $name" if {$GIT_COMMITTER_IDENT == {}} {
if {[$ui_comm get {end -1c linestart} {end -1c}] != $str} { if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
$ui_comm insert end "\n" error_popup "Unable to obtain your identity:\n$err"
$ui_comm insert end $str return
$ui_comm see end
}
} }
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
} }
} }