aboutsummaryrefslogtreecommitdiff
path: root/git-gui
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2006-11-18 21:07:05 -0500
committerShawn O. Pearce <spearce@spearce.org>2006-11-18 22:46:07 -0500
commitd63efae2816a277e40a379eb5c5f23f2a656fddc (patch)
tree80e32b7481a9d5f12af9312c769d1e656c35054c /git-gui
parent24ac9b752d6df7ab309826d487fbeaae53806025 (diff)
downloadgit-d63efae2816a277e40a379eb5c5f23f2a656fddc.tar.gz
git-d63efae2816a277e40a379eb5c5f23f2a656fddc.tar.xz
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>
Diffstat (limited to 'git-gui')
-rwxr-xr-xgit-gui40
1 files changed, 25 insertions, 15 deletions
diff --git a/git-gui b/git-gui
index 5c6af8940..7630a2d2e 100755
--- a/git-gui
+++ b/git-gui
@@ -732,10 +732,31 @@ proc create_new_commit {} {
rescan {set ui_status_value {Ready.}}
}
+set GIT_COMMITTER_IDENT {}
+
+proc committer_ident {} {
+ global GIT_COMMITTER_IDENT
+
+ if {$GIT_COMMITTER_IDENT eq {}} {
+ if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
+ error_popup "Unable to obtain your identity:\n\n$err"
+ return {}
+ }
+ if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
+ $me me GIT_COMMITTER_IDENT]} {
+ error_popup "Invalid GIT_COMMITTER_IDENT:\n\n$me"
+ return {}
+ }
+ }
+
+ return $GIT_COMMITTER_IDENT
+}
+
proc commit_tree {} {
global HEAD commit_type file_states ui_comm repo_config
if {![lock_index update]} return
+ if {[committer_ident] eq {}} return
# -- Our in memory state should match the repository.
#
@@ -1911,24 +1932,13 @@ proc do_include_all {} {
[array names file_states]
}
-set GIT_COMMITTER_IDENT {}
-
proc do_signoff {} {
- global ui_comm GIT_COMMITTER_IDENT
+ global ui_comm
- if {$GIT_COMMITTER_IDENT eq {}} {
- if {[catch {set me [exec git var GIT_COMMITTER_IDENT]} err]} {
- error_popup "Unable to obtain your identity:\n\n$err"
- return
- }
- if {![regexp {^(.*) [0-9]+ [-+0-9]+$} \
- $me me GIT_COMMITTER_IDENT]} {
- error_popup "Invalid GIT_COMMITTER_IDENT:\n\n$me"
- return
- }
- }
+ set me [committer_ident]
+ if {$me eq {}} return
- set sob "Signed-off-by: $GIT_COMMITTER_IDENT"
+ set sob "Signed-off-by: $me"
set last [$ui_comm get {end -1c linestart} {end -1c}]
if {$last ne $sob} {
$ui_comm edit separator