@matheusbsbs / matheus-bagliano / commits / 82cb8706bb
Fork 0

git-gui: Remove combined diff showing behavior.

The combined diff format can be very confusing, especially to new users who may not even be familiar with a standard two way diff format. So for files which are already staged for commit and which are modifed in the working directory we should show two different diffs, depending on which side the user clicked on. If the user clicks on the "Changes To Be Committed" side then we should show them the PARENT<->index difference. This is the set of changes they will actually commit. If the user clicks on the "Changed But Not Updated" side we should show them the index<->working directory difference. This is the set of changes which will not be committed, as they have not been staged into the index. This is especially useful when merging, as the "Changed But Not Updated" files are the ones that need merge conflict resolution, and the diff here is the conflict hunks and/or any evil merge created by the user. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jan 21, 2007 at 11:54 UTC 82cb8706bb9f4f43c72e0228ad33d91c29448f3f
1 file changed +25 -17
git-gui.sh
+25 -17
@@ -556,13 +556,14 @@ proc clear_diff {} {
556 }
557
558 proc reshow_diff {} {
559 - global current_diff_path ui_status_value file_states
559 + global ui_status_value file_states
560 + global current_diff_path current_diff_side
561
562 if {$current_diff_path eq {}
563 || [catch {set s $file_states($current_diff_path)}]} {
564 clear_diff
565 } else {
565 - show_diff $current_diff_path
566 + show_diff $current_diff_path $current_diff_side
567 }
568 }
569
@@ -595,10 +596,11 @@ files list, to prevent possible confusion.
596 display_file $path __
597 }
598
598 -proc show_diff {path {w {}} {lno {}}} {
599 +proc show_diff {path w {lno {}}} {
600 global file_states file_lists
601 global is_3way_diff diff_active repo_config
601 - global ui_diff current_diff_path ui_status_value
602 + global ui_diff ui_status_value ui_index ui_workdir
603 + global current_diff_path current_diff_side
604
605 if {$diff_active || ![lock_index read]} return
606
@@ -621,20 +623,12 @@ proc show_diff {path {w {}} {lno {}}} {
623 set is_3way_diff 0
624 set diff_active 1
625 set current_diff_path $path
626 + set current_diff_side $w
627 set ui_status_value "Loading diff of [escape_path $path]..."
628
626 - set cmd [list | git diff-index]
627 - lappend cmd --no-color
628 - if {$repo_config(gui.diffcontext) > 0} {
629 - lappend cmd "-U$repo_config(gui.diffcontext)"
630 - }
631 - lappend cmd -p
632 -
633 - switch $m {
634 - MM {
635 - lappend cmd -c
636 - }
637 - _O {
629 + # - Git won't give us the diff, there's nothing to compare to!
630 + #
631 + if {$m eq {_O}} {
632 if {[catch {
633 set fd [open $path r]
634 set content [read $fd]
@@ -654,9 +648,23 @@ proc show_diff {path {w {}} {lno {}}} {
648 set ui_status_value {Ready.}
649 return
650 }
651 +
652 + set cmd [list | git]
653 + if {$w eq $ui_index} {
654 + lappend cmd diff-index
655 + lappend cmd --cached
656 + } elseif {$w eq $ui_workdir} {
657 + lappend cmd diff-files
658 }
659
659 - lappend cmd [PARENT]
660 + lappend cmd -p
661 + lappend cmd --no-color
662 + if {$repo_config(gui.diffcontext) > 0} {
663 + lappend cmd "-U$repo_config(gui.diffcontext)"
664 + }
665 + if {$w eq $ui_index} {
666 + lappend cmd [PARENT]
667 + }
668 lappend cmd --
669 lappend cmd $path
670