1 # git-gui merge conflict resolution
2 # parts based on git-mergetool (c) 2006 Theodore Y. Ts'o
4 proc merge_resolve_one
{stage
} {
5 global current_diff_path
8 1 { set target
[mc
"the base version"] }
9 2 { set target
[mc
"this branch"] }
10 3 { set target
[mc
"the other branch"] }
13 set op_question
[mc
"Force resolution to %s?
14 Note that the diff shows only conflicting changes.
16 %s will be overwritten.
18 This operation can be undone only by restarting the merge." \
19 $target [short_path
$current_diff_path]]
21 if {[ask_popup
$op_question] eq
{yes
}} {
22 merge_load_stages
$current_diff_path [list merge_force_stage
$stage]
26 proc merge_add_resolution
{path
} {
27 global current_diff_path
29 if {$path eq
$current_diff_path} {
30 set after {reshow_diff
;}
36 [mc
"Adding resolution for %s" [short_path
$path]] \
38 [concat $after [list ui_ready
]]
41 proc merge_force_stage
{stage
} {
42 global current_diff_path merge_stages
44 if {$merge_stages($stage) ne
{}} {
45 git checkout-index
-f --stage=$stage -- $current_diff_path
47 file delete
-- $current_diff_path
50 merge_add_resolution
$current_diff_path
53 proc merge_load_stages
{path cont
} {
54 global merge_stages_fd merge_stages merge_stages_buf
56 if {[info exists merge_stages_fd
]} {
57 catch { kill_file_process
$merge_stages_fd }
58 catch { close $merge_stages_fd }
61 set merge_stages
(0) {}
62 set merge_stages
(1) {}
63 set merge_stages
(2) {}
64 set merge_stages
(3) {}
65 set merge_stages_buf
{}
67 set merge_stages_fd
[eval git_read ls-files
-u -z -- $path]
69 fconfigure $merge_stages_fd -blocking 0 -translation binary -encoding binary
70 fileevent $merge_stages_fd readable
[list read_merge_stages
$merge_stages_fd $cont]
73 proc read_merge_stages
{fd cont
} {
74 global merge_stages_buf merge_stages_fd merge_stages
76 append merge_stages_buf
[read $fd]
77 set pck
[split $merge_stages_buf "\0"]
78 set merge_stages_buf
[lindex $pck end
]
80 if {[eof $fd] && $merge_stages_buf ne
{}} {
82 set merge_stages_buf
{}
85 foreach p
[lrange $pck 0 end-1
] {
86 set fcols
[split $p "\t"]
87 set cols
[split [lindex $fcols 0] " "]
88 set stage
[lindex $cols 2]
90 set merge_stages
($stage) [lrange $cols 0 1]