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 <orgad.shaneh@audiocodes.com>
Orgad Shaneh committed
Apr 11, 2016 at 09:57 UTC
7e71adc77fb08021235006e88f255e5e40d25662
1 file changed
+19
lib/commit.tcl
+19
@@ -1,8 +1,13 @@
1
# git-gui misc. commit reading/writing support
2
# Copyright (C) 2006, 2007 Shawn Pearce
3
4
+set author_name ""
5
+set author_email ""
6
+set author_date ""
7
+
8
proc load_last_commit {} {
9
global HEAD PARENT MERGE_HEAD commit_type ui_comm
10
+ global author_name author_email author_date
11
global repo_config
12
13
if {[llength $PARENT] == 0} {
@@ -34,6 +39,10 @@ You are currently in the middle of a merge that has not been fully completed. Y
39
lappend parents [string range $line 7 end]
40
} elseif {[string match {encoding *} $line]} {
41
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
46
}
47
}
48
set msg [read $fd]
@@ -107,8 +116,12 @@ proc do_signoff {} {
116
117
proc create_new_commit {} {
118
global commit_type ui_comm
119
+ global author_name author_email author_date
120
121
set commit_type normal
122
+ set author_name ""
123
+ set author_email ""
124
+ set author_date ""
125
$ui_comm delete 0.0 end
126
$ui_comm edit reset
127
$ui_comm edit modified false
@@ -327,6 +340,7 @@ proc commit_committree {fd_wt curHEAD msg_p} {
340
global ui_comm selected_commit_type
341
global file_states selected_paths rescan_active
342
global repo_config
343
+ global env author_name author_email author_date
344
345
gets $fd_wt tree_id
346
if {[catch {close $fd_wt} err]} {
@@ -366,6 +380,11 @@ A rescan will be automatically started now.
380
}
381
}
382
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
+ }
388
# -- Create the commit.
389
#
390
set cmd [list commit-tree $tree_id]