1
1
# git-gui misc. commit reading/writing support
2
2
# Copyright (C) 2006, 2007 Shawn Pearce
3
3
4
- set author_name " "
5
- set author_email " "
6
- set author_date " "
7
-
8
4
proc load_last_commit {} {
9
- global HEAD PARENT MERGE_HEAD commit_type ui_comm
10
- global author_name author_email author_date
5
+ global HEAD PARENT MERGE_HEAD commit_type ui_comm commit_author
11
6
global repo_config
12
7
13
8
if {[llength $PARENT ] == 0} {
@@ -40,9 +35,7 @@ You are currently in the middle of a merge that has not been fully completed. Y
40
35
} elseif {[string match {encoding *} $line ]} {
41
36
set enc [string tolower [string range $line 9 end]]
42
37
} elseif {[regexp "author (.*)\\ s<(.*)>\\ s(\\ d.*$)" $line all name email time]} {
43
- set author_name $name
44
- set author_email $email
45
- set author_date $time
38
+ set commit_author [list name $name email $email date $time ]
46
39
}
47
40
}
48
41
set msg [read $fd ]
@@ -115,13 +108,10 @@ proc do_signoff {} {
115
108
}
116
109
117
110
proc create_new_commit {} {
118
- global commit_type ui_comm
119
- global author_name author_email author_date
111
+ global commit_type ui_comm commit_author
120
112
121
113
set commit_type normal
122
- set author_name " "
123
- set author_email " "
124
- set author_date " "
114
+ unset -nocomplain commit_author
125
115
$ui_comm delete 0.0 end
126
116
$ui_comm edit reset
127
117
$ui_comm edit modified false
@@ -335,12 +325,12 @@ proc commit_writetree {curHEAD msg_p} {
335
325
}
336
326
337
327
proc commit_committree {fd_wt curHEAD msg_p} {
338
- global HEAD PARENT MERGE_HEAD commit_type
328
+ global HEAD PARENT MERGE_HEAD commit_type commit_author
339
329
global current_branch
340
330
global ui_comm selected_commit_type
341
331
global file_states selected_paths rescan_active
342
332
global repo_config
343
- global env author_name author_email author_date
333
+ global env
344
334
345
335
gets $fd_wt tree_id
346
336
if {[catch {close $fd_wt } err]} {
@@ -380,10 +370,8 @@ A rescan will be automatically started now.
380
370
}
381
371
}
382
372
383
- if {$author_name ne " " } {
384
- set env(GIT_AUTHOR_NAME) $author_name
385
- set env(GIT_AUTHOR_EMAIL) $author_email
386
- set env(GIT_AUTHOR_DATE) $author_date
373
+ if {[info exists commit_author]} {
374
+ set old_author [commit_author_ident $commit_author ]
387
375
}
388
376
# -- Create the commit.
389
377
#
@@ -397,8 +385,14 @@ A rescan will be automatically started now.
397
385
error_popup [strcat [mc " commit-tree failed:" ] " \n\n $err " ]
398
386
ui_status [mc " Commit failed." ]
399
387
unlock_index
388
+ unset -nocomplain commit_author
389
+ commit_author_reset $old_author
400
390
return
401
391
}
392
+ if {[info exists commit_author]} {
393
+ unset -nocomplain commit_author
394
+ commit_author_reset $old_author
395
+ }
402
396
403
397
# -- Update the HEAD ref.
404
398
#
@@ -525,3 +519,20 @@ proc commit_postcommit_wait {fd_ph cmt_id} {
525
519
}
526
520
fconfigure $fd_ph -blocking 0
527
521
}
522
+
523
+ proc commit_author_ident {details} {
524
+ global env
525
+ array set author $details
526
+ set old [array get env GIT_AUTHOR_*]
527
+ set env(GIT_AUTHOR_NAME) $author(name)
528
+ set env(GIT_AUTHOR_EMAIL) $author(email)
529
+ set env(GIT_AUTHOR_DATE) $author(date)
530
+ return $old
531
+ }
532
+ proc commit_author_reset {details} {
533
+ global env
534
+ unset env(GIT_AUTHOR_NAME) env(GIT_AUTHOR_EMAIL) env(GIT_AUTHOR_DATE)
535
+ if {$details ne {}} {
536
+ array set env $details
537
+ }
538
+ }
0 commit comments