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>
Shawn O. Pearce committed
Nov 8, 2006 at 23:05 UTC
97bf01c46526a680fb04ac88cb0ecaefbd3b4d7f
1 file changed
+19
-10
git-gui
+19
-10
@@ -1398,19 +1398,28 @@ proc do_include_all {} {
1398
}
1399
}
1400
1401
+set GIT_COMMITTER_IDENT {}
1402
+
1403
proc do_signoff {} {
1402
- global ui_comm
1404
+ global ui_comm GIT_COMMITTER_IDENT
1405
1404
- catch {
1405
- set me [exec git var GIT_COMMITTER_IDENT]
1406
- if {[regexp {(.*) [0-9]+ [-+0-9]+$} $me me name]} {
1407
- set str "Signed-off-by: $name"
1408
- if {[$ui_comm get {end -1c linestart} {end -1c}] != $str} {
1409
- $ui_comm insert end "\n"
1410
- $ui_comm insert end $str
1411
- $ui_comm see end
1412
- }
1406
+ if {$GIT_COMMITTER_IDENT == {}} {
1407
+ if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
1408
+ error_popup "Unable to obtain your identity:\n$err"
1409
+ return
1410
}
1411
+ if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
1412
+ $me me GIT_COMMITTER_IDENT]} {
1413
+ error_popup "Invalid GIT_COMMITTER_IDENT:\n$me"
1414
+ return
1415
+ }
1416
+ }
1417
+
1418
+ set str "Signed-off-by: $GIT_COMMITTER_IDENT"
1419
+ if {[$ui_comm get {end -1c linestart} {end -1c}] != $str} {
1420
+ $ui_comm insert end "\n"
1421
+ $ui_comm insert end $str
1422
+ $ui_comm see end
1423
}
1424
}
1425