2
2
# Copyright (C) 2006, 2007 Shawn Pearce
3
3
4
4
proc load_last_commit {} {
5
- global HEAD PARENT MERGE_HEAD commit_type ui_comm
5
+ global HEAD PARENT MERGE_HEAD commit_type ui_comm commit_author
6
6
global repo_config
7
7
8
8
if {[llength $PARENT ] == 0} {
@@ -34,6 +34,8 @@ You are currently in the middle of a merge that has not been fully completed. Y
34
34
lappend parents [string range $line 7 end]
35
35
} elseif {[string match {encoding *} $line ]} {
36
36
set enc [string tolower [string range $line 9 end]]
37
+ } elseif {[regexp "author (.*)\\ s<(.*)>\\ s(\\ d.*$)" $line all name email time]} {
38
+ set commit_author [list name $name email $email date $time ]
37
39
}
38
40
}
39
41
set msg [read $fd ]
@@ -106,9 +108,10 @@ proc do_signoff {} {
106
108
}
107
109
108
110
proc create_new_commit {} {
109
- global commit_type ui_comm
111
+ global commit_type ui_comm commit_author
110
112
111
113
set commit_type normal
114
+ unset -nocomplain commit_author
112
115
$ui_comm delete 0.0 end
113
116
$ui_comm edit reset
114
117
$ui_comm edit modified false
@@ -322,11 +325,12 @@ proc commit_writetree {curHEAD msg_p} {
322
325
}
323
326
324
327
proc commit_committree {fd_wt curHEAD msg_p} {
325
- global HEAD PARENT MERGE_HEAD commit_type
328
+ global HEAD PARENT MERGE_HEAD commit_type commit_author
326
329
global current_branch
327
330
global ui_comm selected_commit_type
328
331
global file_states selected_paths rescan_active
329
332
global repo_config
333
+ global env
330
334
331
335
gets $fd_wt tree_id
332
336
if {[catch {close $fd_wt } err]} {
@@ -366,6 +370,9 @@ A rescan will be automatically started now.
366
370
}
367
371
}
368
372
373
+ if {[info exists commit_author]} {
374
+ set old_author [commit_author_ident $commit_author ]
375
+ }
369
376
# -- Create the commit.
370
377
#
371
378
set cmd [list commit-tree $tree_id ]
@@ -381,8 +388,14 @@ A rescan will be automatically started now.
381
388
error_popup [strcat [mc " commit-tree failed:" ] " \n\n $err " ]
382
389
ui_status [mc " Commit failed." ]
383
390
unlock_index
391
+ unset -nocomplain commit_author
392
+ commit_author_reset $old_author
384
393
return
385
394
}
395
+ if {[info exists commit_author]} {
396
+ unset -nocomplain commit_author
397
+ commit_author_reset $old_author
398
+ }
386
399
387
400
# -- Update the HEAD ref.
388
401
#
@@ -509,3 +522,20 @@ proc commit_postcommit_wait {fd_ph cmt_id} {
509
522
}
510
523
fconfigure $fd_ph -blocking 0
511
524
}
525
+
526
+ proc commit_author_ident {details} {
527
+ global env
528
+ array set author $details
529
+ set old [array get env GIT_AUTHOR_*]
530
+ set env(GIT_AUTHOR_NAME) $author(name)
531
+ set env(GIT_AUTHOR_EMAIL) $author(email)
532
+ set env(GIT_AUTHOR_DATE) $author(date)
533
+ return $old
534
+ }
535
+ proc commit_author_reset {details} {
536
+ global env
537
+ unset env(GIT_AUTHOR_NAME) env(GIT_AUTHOR_EMAIL) env(GIT_AUTHOR_DATE)
538
+ if {$details ne {}} {
539
+ array set env $details
540
+ }
541
+ }
0 commit comments