Skip to content

Commit f5dccd5

Browse files
committed
gitk: enable --merge after conflicted cherry-picks and reverts
When a 'git cherry-pick' or 'git revert' fails, it leaves behind corresponding "*_HEAD" files that can be treated analogous to MERGE_HEAD. Show the symmetric difference between those commits and HEAD when the --merge option is given in the same way that a conflicted merge is shown. Signed-off-by: Johannes Sixt <j6t@kdbg.org>
1 parent e244588 commit f5dccd5

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

gitk

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ proc unmerged_files {files} {
156156
proc parseviewargs {n arglist} {
157157
global vdatemode vmergeonly vflags vdflags vrevs vfiltered vorigargs env
158158
global vinlinediff
159-
global worddiff git_version
159+
global worddiff git_version gitdir
160160

161161
set vdatemode($n) 0
162162
set vmergeonly($n) 0
@@ -255,7 +255,14 @@ proc parseviewargs {n arglist} {
255255
"--merge" {
256256
set vmergeonly($n) 1
257257
# git rev-parse doesn't understand --merge
258-
lappend revargs --gitk-symmetric-diff-marker MERGE_HEAD...HEAD
258+
# check MERGE_HEAD again at the end so that it appears in
259+
# the error message when none of the _HEADs is found
260+
foreach merge_head {MERGE_HEAD CHERRY_PICK_HEAD REVERT_HEAD REBASE_HEAD MERGE_HEAD} {
261+
if {[file exists [file join $gitdir $merge_head]]} {
262+
break
263+
}
264+
}
265+
lappend revargs --gitk-symmetric-diff-marker $merge_head...HEAD
259266
}
260267
"--no-replace-objects" {
261268
set env(GIT_NO_REPLACE_OBJECTS) "1"

0 commit comments

Comments
 (0)