@matheusbsbs / matheus-bagliano / commits / 15e350552d
Fork 0

gitk: Make cherry-pick call git-citool on conflicts

Now that git-gui has facilities to help users resolve conflicts, it makes sense to launch it from other GUI tools when they happen. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>

Alexander Gavrilov committed Nov 2, 2008 at 21:59 UTC 15e350552db1c0e8ede0af4f1f07dbbc9090e420
1 file changed +39 -1
gitk
+39 -1
@@ -8088,6 +8088,32 @@ proc mkbrgo {top} {
8088 }
8089 }
8090
8091 +proc exec_citool {tool_args {baseid {}}} {
8092 + global commitinfo env
8093 +
8094 + set save_env [array get env GIT_AUTHOR_*]
8095 +
8096 + if {$baseid ne {}} {
8097 + if {![info exists commitinfo($baseid)]} {
8098 + getcommit $baseid
8099 + }
8100 + set author [lindex $commitinfo($baseid) 1]
8101 + set date [lindex $commitinfo($baseid) 2]
8102 + if {[regexp {^\s*(\S.*\S|\S)\s*<(.*)>\s*$} \
8103 + $author author name email]
8104 + && $date ne {}} {
8105 + set env(GIT_AUTHOR_NAME) $name
8106 + set env(GIT_AUTHOR_EMAIL) $email
8107 + set env(GIT_AUTHOR_DATE) $date
8108 + }
8109 + }
8110 +
8111 + eval exec git citool $tool_args &
8112 +
8113 + array unset env GIT_AUTHOR_*
8114 + array set env $save_env
8115 +}
8116 +
8117 proc cherrypick {} {
8118 global rowmenuid curview
8119 global mainhead mainheadid
@@ -8106,7 +8132,19 @@ proc cherrypick {} {
8132 # no error occurs, and exec takes that as an indication of error...
8133 if {[catch {exec sh -c "git cherry-pick -r $rowmenuid 2>&1"} err]} {
8134 notbusy cherrypick
8109 - error_popup $err
8135 + if {[regexp -line \
8136 + {Entry '(.*)' would be overwritten by merge} $err msg fname]} {
8137 + error_popup [mc "Cherry-pick failed:
8138 +file '%s' had local modifications.
8139 +
8140 +Please commit, reset or stash your changes." $fname]
8141 + } elseif {[regexp -line {^CONFLICT \(.*\):} $err msg]} {
8142 + # Force citool to read MERGE_MSG
8143 + file delete [file join [gitdir] "GITGUI_MSG"]
8144 + exec_citool {} $rowmenuid
8145 + } else {
8146 + error_popup $err
8147 + }
8148 return
8149 }
8150 set newhead [exec git rev-parse HEAD]