# git-gui misc. commit reading/writing support
# Copyright (C) 2006, 2007 Shawn Pearce
+set author_name ""
+set author_email ""
+set author_date ""
+
proc load_last_commit {} {
global HEAD PARENT MERGE_HEAD commit_type ui_comm
+ global author_name author_email author_date
global repo_config
if {[llength $PARENT] == 0} {
lappend parents [string range $line 7 end]
} elseif {[string match {encoding *} $line]} {
set enc [string tolower [string range $line 9 end]]
+ } elseif {[regexp "author (.*)\\s<(.*)>\\s(\\d.*$)" $line all name email time]} {
+ set author_name $name
+ set author_email $email
+ set author_date $time
}
}
set msg [read $fd]
proc create_new_commit {} {
global commit_type ui_comm
+ global author_name author_email author_date
set commit_type normal
+ set author_name ""
+ set author_email ""
+ set author_date ""
$ui_comm delete 0.0 end
$ui_comm edit reset
$ui_comm edit modified false
#
set files_ready 0
foreach path [array names file_states] {
- switch -glob -- [lindex $file_states($path) 0] {
+ set s $file_states($path)
+ switch -glob -- [lindex $s 0] {
_? {continue}
A? -
D? -
- T_ -
+ T? -
M? {set files_ready 1}
_U -
U? {
}
proc commit_commitmsg {curHEAD msg_p} {
+ global is_detached repo_config
global pch_error
+ if {$is_detached
+ && ![file exists [gitdir rebase-merge head-name]]
+ && [is_config_true gui.warndetachedcommit]} {
+ set msg [mc "You are about to commit on a detached head.\
+This is a potentially dangerous thing to do because if you switch\
+to another branch you will lose your changes and it can be difficult\
+to retrieve them later from the reflog. You should probably cancel this\
+commit and create a new branch to continue.\n\
+\n\
+Do you really want to proceed with your Commit?"]
+ if {[ask_popup $msg] ne yes} {
+ unlock_index
+ return
+ }
+ }
+
# -- Run the commit-msg hook.
#
set fd_ph [githook_read commit-msg $msg_p]
global ui_comm selected_commit_type
global file_states selected_paths rescan_active
global repo_config
+ global env author_name author_email author_date
gets $fd_wt tree_id
if {[catch {close $fd_wt} err]} {
}
}
+ if {$author_name ne ""} {
+ set env(GIT_AUTHOR_NAME) $author_name
+ set env(GIT_AUTHOR_EMAIL) $author_email
+ set env(GIT_AUTHOR_DATE) $author_date
+ }
# -- Create the commit.
#
set cmd [list commit-tree $tree_id]
catch {file delete [gitdir MERGE_MSG]}
catch {file delete [gitdir SQUASH_MSG]}
catch {file delete [gitdir GITGUI_MSG]}
+ catch {file delete [gitdir CHERRY_PICK_HEAD]}
# -- Let rerere do its thing.
#
}
AM -
AD -
+ AT -
+ TM -
+ TD -
MM -
+ MT -
MD {
set file_states($path) [list \
_[string index $m 1] \