@matheusbsbs / matheus-bagliano / commits / bd1e2b4028
Fork 0

git-gui: Misc. nit type of bug fixes.

* Make sure we are in the top level working directory. This way we can access files using their repository path. * Reload the diff viewer if the current file's status has changed; as the diff may now be different. * Correctly handle the 'AD' file state: added but now gone from the working directory. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 6, 2006 at 22:03 UTC bd1e2b4028e183f7b4d564aad69c3eae8bdb661a
1 file changed +29 -7
git-gui
+29 -7
@@ -266,6 +266,9 @@ proc show_diff {path} {
266 $ui_diff conf -state normal
267 $ui_diff insert end $content
268 $ui_diff conf -state disabled
269 + set diff_active 0
270 + unlock_index
271 + set ui_status_value {Ready.}
272 return
273 }
274 }
@@ -482,8 +485,7 @@ A good commit message has the following format:
485 set ui_status_value {Committing changes...}
486
487 set fd_wt [open "| git write-tree" r]
485 - fileevent $fd_wt readable \
486 - [list commit_stage2 $fd_wt $curHEAD $msg]
488 + fileevent $fd_wt readable [list commit_stage2 $fd_wt $curHEAD $msg]
489 }
490
491 proc commit_stage2 {fd_wt curHEAD msg} {
@@ -510,8 +512,8 @@ proc commit_stage2 {fd_wt curHEAD msg} {
512 if {$commit_type == {merge}} {
513 if {[catch {
514 set fd_mh [open [file join $gitdir MERGE_HEAD] r]
513 - while {[gets $fd_mh merge_head] > 0} {
514 - lappend -p $merge_head
515 + while {[gets $fd_mh merge_head] >= 0} {
516 + lappend cmd -p $merge_head
517 }
518 close $fd_mh
519 } err]} {
@@ -576,6 +578,8 @@ proc commit_stage2 {fd_wt curHEAD msg} {
578
579 set commit_type {}
580 set commit_active 0
581 + set HEAD $cmt_id
582 + set PARENT $cmt_id
583 unlock_index
584 update_status "Changes committed as $cmt_id."
585 }
@@ -739,7 +743,7 @@ proc update_index {path} {
743 }
744
745 proc toggle_mode {path} {
742 - global file_states
746 + global file_states ui_fname_value
747
748 set s $file_states($path)
749 set m [lindex $s 0]
@@ -749,12 +753,16 @@ proc toggle_mode {path} {
753 _O {set new A*}
754 _M -
755 MM {set new M*}
756 + AD -
757 _D {set new D*}
758 default {return}
759 }
760
761 with_update_index {update_index $path}
762 display_file $path $new
763 + if {$ui_fname_value == $path} {
764 + show_diff $path
765 + }
766 }
767
768 ######################################################################
@@ -843,6 +851,7 @@ foreach i {
851 {_O o plain "Untracked"}
852 {A_ o fulltick "Added"}
853 {AM o parttick "Partially added"}
854 + {AD o question "Added (but now gone)"}
855
856 {_D i question "Missing"}
857 {D_ i removed "Removed"}
@@ -1261,10 +1270,18 @@ lappend disable_on_lock {.vpane.commarea.buttons.commit conf -state}
1270 # -- Commit Message Buffer
1271 frame .vpane.commarea.buffer
1272 set ui_comm .vpane.commarea.buffer.t
1264 -label .vpane.commarea.buffer.l -text {Commit Message:} \
1273 +set ui_coml .vpane.commarea.buffer.l
1274 +label $ui_coml -text {Commit Message:} \
1275 -anchor w \
1276 -justify left \
1277 -font $mainfont
1278 +trace add variable commit_type write {uplevel #0 {
1279 + switch -glob $commit_type \
1280 + initial {$ui_coml conf -text {Initial Commit Message:}} \
1281 + amend {$ui_coml conf -text {Amended Commit Message:}} \
1282 + merge {$ui_coml conf -text {Merge Commit Message:}} \
1283 + * {$ui_coml conf -text {Commit Message:}}
1284 +}}
1285 text $ui_comm -background white -borderwidth 1 \
1286 -relief sunken \
1287 -width 75 -height 10 -wrap none \
@@ -1272,7 +1289,7 @@ text $ui_comm -background white -borderwidth 1 \
1289 -yscrollcommand {.vpane.commarea.buffer.sby set} \
1290 -cursor $maincursor
1291 scrollbar .vpane.commarea.buffer.sby -command [list $ui_comm yview]
1275 -pack .vpane.commarea.buffer.l -side top -fill x
1292 +pack $ui_coml -side top -fill x
1293 pack .vpane.commarea.buffer.sby -side right -fill y
1294 pack $ui_comm -side left -fill y
1295 pack .vpane.commarea.buffer -side left -fill y
@@ -1315,6 +1332,11 @@ if {[catch {set gitdir [exec git rev-parse --git-dir]} err]} {
1332 show_msg {} . "Cannot find the git directory: $err"
1333 exit 1
1334 }
1335 +set cdup [exec git rev-parse --show-cdup]
1336 +if {$cdup != ""} {
1337 + cd $cdup
1338 +}
1339 +unset cdup
1340
1341 set appname [lindex [file split $argv0] end]
1342 if {$appname == {git-citool}} {