Skip to content

Commit 887a791

Browse files
committed
gitk: Improve cherry-pick error handling
This adds to the regexps that are used to work out what sort of error we encountered in trying to do a cherry-pick so that it recognizes some additional common error messages. It adds a confirmation dialog when the error is a merge conflict so the user can choose whether or not to run git citool. Finally, it arranges to update the display after a cherry-pick failed so that any local changes made by the cherry-pick become visible. Signed-off-by: Paul Mackerras <[email protected]>
1 parent 15e3505 commit 887a791

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

gitk

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8133,18 +8133,25 @@ proc cherrypick {} {
81338133
if {[catch {exec sh -c "git cherry-pick -r $rowmenuid 2>&1"} err]} {
81348134
notbusy cherrypick
81358135
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
8136+
{Entry '(.*)' (would be overwritten by merge|not uptodate)} \
8137+
$err msg fname]} {
8138+
error_popup [mc "Cherry-pick failed because of local changes\
8139+
to file '%s'.\nPlease commit, reset or stash\
8140+
your changes and try again." $fname]
8141+
} elseif {[regexp -line \
8142+
{^(CONFLICT \(.*\):|Automatic cherry-pick failed)} \
8143+
$err]} {
8144+
if {[confirm_popup [mc "Cherry-pick failed because of merge\
8145+
conflict.\nDo you wish to run git citool to\
8146+
resolve it?"]]} {
8147+
# Force citool to read MERGE_MSG
8148+
file delete [file join [gitdir] "GITGUI_MSG"]
8149+
exec_citool {} $rowmenuid
8150+
}
81458151
} else {
81468152
error_popup $err
81478153
}
8154+
run updatecommits
81488155
return
81498156
}
81508157
set newhead [exec git rev-parse HEAD]

0 commit comments

Comments
 (0)