Skip to content

Commit aa12732

Browse files
orgadsGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
git-gui: Do not reset author details on amend
git commit --amend preserves the author details unless --reset-author is given. git-gui discards the author details on amend. Fix by reading the author details along with the commit message, and setting the appropriate environment variables required for preserving them. Reported long ago in the mailing list[1]. [1] http://article.gmane.org/gmane.comp.version-control.git/243921 Signed-off-by: Orgad Shaneh <[email protected]>
1 parent 8107f15 commit aa12732

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

git-gui/lib/commit.tcl

+19
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# git-gui misc. commit reading/writing support
22
# Copyright (C) 2006, 2007 Shawn Pearce
33

4+
set author_name ""
5+
set author_email ""
6+
set author_date ""
7+
48
proc load_last_commit {} {
59
global HEAD PARENT MERGE_HEAD commit_type ui_comm
10+
global author_name author_email author_date
611
global repo_config
712

813
if {[llength $PARENT] == 0} {
@@ -34,6 +39,10 @@ You are currently in the middle of a merge that has not been fully completed. Y
3439
lappend parents [string range $line 7 end]
3540
} elseif {[string match {encoding *} $line]} {
3641
set enc [string tolower [string range $line 9 end]]
42+
} 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
3746
}
3847
}
3948
set msg [read $fd]
@@ -107,8 +116,12 @@ proc do_signoff {} {
107116

108117
proc create_new_commit {} {
109118
global commit_type ui_comm
119+
global author_name author_email author_date
110120

111121
set commit_type normal
122+
set author_name ""
123+
set author_email ""
124+
set author_date ""
112125
$ui_comm delete 0.0 end
113126
$ui_comm edit reset
114127
$ui_comm edit modified false
@@ -327,6 +340,7 @@ proc commit_committree {fd_wt curHEAD msg_p} {
327340
global ui_comm selected_commit_type
328341
global file_states selected_paths rescan_active
329342
global repo_config
343+
global env author_name author_email author_date
330344

331345
gets $fd_wt tree_id
332346
if {[catch {close $fd_wt} err]} {
@@ -366,6 +380,11 @@ A rescan will be automatically started now.
366380
}
367381
}
368382

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
387+
}
369388
# -- Create the commit.
370389
#
371390
set cmd [list commit-tree $tree_id]

0 commit comments

Comments
 (0)