Skip to content

Commit

Permalink
git-gui: Don't allow users to commit a bad octopus merge.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shawn O. Pearce committed Jan 26, 2007
1 parent ee3cfb5 commit dff7e88
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ proc warn_popup {msg} {
eval $cmd
}

proc info_popup {msg} {
proc info_popup {msg {parent .}} {
set title [appname]
if {[reponame] ne {}} {
append title " ([reponame])"
}
tk_messageBox \
-parent . \
-parent $parent \
-icon info \
-type ok \
-title $title \
Expand Down Expand Up @@ -2697,16 +2697,36 @@ than 15 branches, merge the branches in batches.
set msg "Merging $current_branch, [join $names {, }]"
set ui_status_value "$msg..."
set cons [new_console "Merge" $msg]
console_exec $cons $cmd finish_merge
console_exec $cons $cmd [list finish_merge $revcnt]
bind $w <Destroy> {}
destroy $w
}

proc finish_merge {w ok} {
proc finish_merge {revcnt w ok} {
console_done $w $ok
if {$ok} {
set msg {Merge completed successfully.}
} else {
if {$revcnt != 1} {
info_popup "Octopus merge failed.
Your merge of $revcnt branches has failed.
There are file-level conflicts between the
branches which must be resolved manually.
The working directory will now be reset.
You can attempt this merge again
by merging only one branch at a time." $w

set fd [open "| git read-tree --reset -u HEAD" r]
fconfigure $fd -blocking 0 -translation binary
fileevent $fd readable [list reset_hard_wait $fd]
set ui_status_value {Aborting... please wait...}
return
}

set msg {Merge failed. Conflict resolution is required.}
}
unlock_index
Expand Down

0 comments on commit dff7e88

Please sign in to comment.