git-gui: Verify the user has GIT_COMMITTER_IDENT before comitting.
Since git-commit also checks that the user has a GIT_COMMITTER_IDENT value before it lets the user make a commit we should do the same check here in git-gui. We cache the result and assume that the user won't do something which would change the status of GIT_COMMITTER_IDENT while we are running. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Nov 18, 2006 at 21:07 UTC
d63efae2816a277e40a379eb5c5f23f2a656fddc
1 file changed
+25
-15
git-gui
+25
-15
@@ -732,10 +732,31 @@ proc create_new_commit {} {
732
rescan {set ui_status_value {Ready.}}
733
}
734
735
+set GIT_COMMITTER_IDENT {}
736
+
737
+proc committer_ident {} {
738
+ global GIT_COMMITTER_IDENT
739
+
740
+ if {$GIT_COMMITTER_IDENT eq {}} {
741
+ if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
742
+ error_popup "Unable to obtain your identity:\n\n$err"
743
+ return {}
744
+ }
745
+ if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
746
+ $me me GIT_COMMITTER_IDENT]} {
747
+ error_popup "Invalid GIT_COMMITTER_IDENT:\n\n$me"
748
+ return {}
749
+ }
750
+ }
751
+
752
+ return $GIT_COMMITTER_IDENT
753
+}
754
+
755
proc commit_tree {} {
756
global HEAD commit_type file_states ui_comm repo_config
757
758
if {![lock_index update]} return
759
+ if {[committer_ident] eq {}} return
760
761
# -- Our in memory state should match the repository.
762
#
@@ -1911,24 +1932,13 @@ proc do_include_all {} {
1932
[array names file_states]
1933
}
1934
1914
-set GIT_COMMITTER_IDENT {}
1915
-
1935
proc do_signoff {} {
1917
- global ui_comm GIT_COMMITTER_IDENT
1936
+ global ui_comm
1937
1919
- if {$GIT_COMMITTER_IDENT eq {}} {
1920
- if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
1921
- error_popup "Unable to obtain your identity:\n\n$err"
1922
- return
1923
- }
1924
- if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
1925
- $me me GIT_COMMITTER_IDENT]} {
1926
- error_popup "Invalid GIT_COMMITTER_IDENT:\n\n$me"
1927
- return
1928
- }
1929
- }
1938
+ set me [committer_ident]
1939
+ if {$me eq {}} return
1940
1931
- set sob "Signed-off-by: $GIT_COMMITTER_IDENT"
1941
+ set sob "Signed-off-by: $me"
1942
set last [$ui_comm get {end -1c linestart} {end -1c}]
1943
if {$last ne $sob} {
1944
$ui_comm edit separator