git-gui: Don't allow users to commit a bad octopus merge.
If an octopus merge goes horribly wrong git-merge will leave the working directory and index dirty, but will not leave behind a MERGE_HEAD file for a later commit. Consequently we won't know its a merge commit and instead would let the user resolve the conflicts and commit a single-parent commit, which is wrong. So now if an octopus merge fails we notify the user that the merge did not work, tell them we will reset the working directory, and suggest that they merge one branch at a time. This prevents the user from committing a bad octopus merge. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jan 26, 2007 at 04:07 UTC
dff7e88febf85b1b8b1b789cd7c99434b70fb19b
1 file changed
+24
-4
git-gui.sh
+24
-4
@@ -187,13 +187,13 @@ proc warn_popup {msg} {
187
eval $cmd
188
}
189
190
-proc info_popup {msg} {
190
+proc info_popup {msg {parent .}} {
191
set title [appname]
192
if {[reponame] ne {}} {
193
append title " ([reponame])"
194
}
195
tk_messageBox \
196
- -parent . \
196
+ -parent $parent \
197
-icon info \
198
-type ok \
199
-title $title \
@@ -2697,16 +2697,36 @@ than 15 branches, merge the branches in batches.
2697
set msg "Merging $current_branch, [join $names {, }]"
2698
set ui_status_value "$msg..."
2699
set cons [new_console "Merge" $msg]
2700
- console_exec $cons $cmd finish_merge
2700
+ console_exec $cons $cmd [list finish_merge $revcnt]
2701
bind $w <Destroy> {}
2702
destroy $w
2703
}
2704
2705
-proc finish_merge {w ok} {
2705
+proc finish_merge {revcnt w ok} {
2706
console_done $w $ok
2707
if {$ok} {
2708
set msg {Merge completed successfully.}
2709
} else {
2710
+ if {$revcnt != 1} {
2711
+ info_popup "Octopus merge failed.
2712
+
2713
+Your merge of $revcnt branches has failed.
2714
+
2715
+There are file-level conflicts between the
2716
+branches which must be resolved manually.
2717
+
2718
+The working directory will now be reset.
2719
+
2720
+You can attempt this merge again
2721
+by merging only one branch at a time." $w
2722
+
2723
+ set fd [open "| git read-tree --reset -u HEAD" r]
2724
+ fconfigure $fd -blocking 0 -translation binary
2725
+ fileevent $fd readable [list reset_hard_wait $fd]
2726
+ set ui_status_value {Aborting... please wait...}
2727
+ return
2728
+ }
2729
+
2730
set msg {Merge failed. Conflict resolution is required.}
2731
}
2732
unlock_index