]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-gui.sh
git-gui: Don't allow merges in the middle of other things.
[git.git] / git-gui.sh
index 0c2dbbebe1287256ff4b3e5c2c086cdd9b491044..ae883f90bd0a755b7cdec98d847491bc001470b0 100755 (executable)
@@ -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 \
@@ -2629,6 +2629,9 @@ The rescan will be automatically started now.
 
        foreach path [array names file_states] {
                switch -glob -- [lindex $file_states($path) 0] {
+               _O {
+                       continue; # and pray it works!
+               }
                U? {
                        error_popup "You are in the middle of a conflicted merge.
 
@@ -2637,6 +2640,18 @@ File [short_path $path] has merge conflicts.
 You must resolve them, add the file, and commit to
 complete the current merge.  Only then can you
 begin another merge.
+"
+                       unlock_index
+                       return 0
+               }
+               ?? {
+                       error_popup "You are in the middle of a change.
+
+File [short_path $path] is modified.
+
+You should complete the current commit before
+starting a merge.  Doing so will help you abort
+a failed merge, should the need arise.
 "
                        unlock_index
                        return 0
@@ -2658,7 +2673,7 @@ proc visualize_local_merge {w} {
 }
 
 proc start_local_merge_action {w} {
-       global HEAD
+       global HEAD ui_status_value current_branch
 
        set cmd [list git merge]
        set names {}
@@ -2694,17 +2709,39 @@ than 15 branches, merge the branches in batches.
                return
        }
 
-       set cons [new_console "Merge" "Merging [join $names {, }]"]
-       console_exec $cons $cmd finish_merge
+       set msg "Merging $current_branch, [join $names {, }]"
+       set ui_status_value "$msg..."
+       set cons [new_console "Merge" $msg]
+       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