]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-gui.sh
git-gui: handle "deleted symlink" diff marker
[git.git] / git-gui.sh
index b25b52fd115490898b06d906a0252f2cb3bbdbbb..6d676097a6a3aeecfda3a752b7344dc88094956c 100755 (executable)
@@ -42,6 +42,8 @@ if {[catch {package require Tcl 8.4} err]
        exit 1
 }
 
+rename send {} ; # What an evil concept...
+
 ######################################################################
 ##
 ## enable verbose loading?
@@ -261,7 +263,7 @@ proc _git_cmd {name} {
                        set s [gets $f]
                        close $f
 
-                       switch -glob -- $s {
+                       switch -glob -- [lindex $s 0] {
                        #!*sh     { set i sh     }
                        #!*perl   { set i perl   }
                        #!*python { set i python }
@@ -275,7 +277,7 @@ proc _git_cmd {name} {
                        if {$interp eq {}} {
                                error "git-$name requires $i (not in PATH)"
                        }
-                       set v [list $interp $p]
+                       set v [concat [list $interp] [lrange $s 1 end] [list $p]]
                } else {
                        # Assume it is builtin to git somehow and we
                        # aren't actually able to see a file for it.
@@ -703,7 +705,15 @@ if {![file isdirectory $_gitdir]} {
        error_popup "Git directory not found:\n\n$_gitdir"
        exit 1
 }
-if {![is_enabled bare]} {
+if {$_prefix ne {}} {
+       regsub -all {[^/]+/} $_prefix ../ cdup
+       if {[catch {cd $cdup} err]} {
+               catch {wm withdraw .}
+               error_popup "Cannot move to top of working directory:\n\n$err"
+               exit 1
+       }
+       unset cdup
+} elseif {![is_enabled bare]} {
        if {[lindex [file split $_gitdir] end] ne {.git}} {
                catch {wm withdraw .}
                error_popup "Cannot use funny .git directory:\n\n$_gitdir"
@@ -738,6 +748,7 @@ set empty_tree {}
 set current_branch {}
 set is_detached 0
 set current_diff_path {}
+set is_3way_diff 0
 set selected_commit_type new
 
 ######################################################################
@@ -2432,20 +2443,19 @@ proc popup_diff_menu {ctxm x y X Y} {
        set ::cursorX $x
        set ::cursorY $y
        if {$::ui_index eq $::current_diff_side} {
-               $ctxm entryconf $::ui_diff_applyhunk \
-                       -state normal \
-                       -label {Unstage Hunk From Commit}
-       } elseif {$current_diff_path eq {}
+               set l "Unstage Hunk From Commit"
+       } else {
+               set l "Stage Hunk For Commit"
+       }
+       if {$::is_3way_diff
+               || $current_diff_path eq {}
                || ![info exists file_states($current_diff_path)]
                || {_O} eq [lindex $file_states($current_diff_path) 0]} {
-               $ctxm entryconf $::ui_diff_applyhunk \
-                       -state disabled \
-                       -label {Stage Hunk For Commit}
+               set s disabled
        } else {
-               $ctxm entryconf $::ui_diff_applyhunk \
-                       -state normal \
-                       -label {Stage Hunk For Commit}
+               set s normal
        }
+       $ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
        tk_popup $ctxm $X $Y
 }
 bind_button3 $ui_diff [list popup_diff_menu $ctxm %x %y %X %Y]