提交 82cb8706 编写于 作者: S Shawn O. Pearce

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: NShawn O. Pearce <spearce@spearce.org>
上级 20a53c02
...@@ -556,13 +556,14 @@ proc clear_diff {} { ...@@ -556,13 +556,14 @@ proc clear_diff {} {
} }
proc reshow_diff {} { proc reshow_diff {} {
global current_diff_path ui_status_value file_states global ui_status_value file_states
global current_diff_path current_diff_side
if {$current_diff_path eq {} if {$current_diff_path eq {}
|| [catch {set s $file_states($current_diff_path)}]} { || [catch {set s $file_states($current_diff_path)}]} {
clear_diff clear_diff
} else { } else {
show_diff $current_diff_path show_diff $current_diff_path $current_diff_side
} }
} }
...@@ -595,10 +596,11 @@ files list, to prevent possible confusion. ...@@ -595,10 +596,11 @@ files list, to prevent possible confusion.
display_file $path __ display_file $path __
} }
proc show_diff {path {w {}} {lno {}}} { proc show_diff {path w {lno {}}} {
global file_states file_lists global file_states file_lists
global is_3way_diff diff_active repo_config global is_3way_diff diff_active repo_config
global ui_diff current_diff_path ui_status_value global ui_diff ui_status_value ui_index ui_workdir
global current_diff_path current_diff_side
if {$diff_active || ![lock_index read]} return if {$diff_active || ![lock_index read]} return
...@@ -621,20 +623,12 @@ proc show_diff {path {w {}} {lno {}}} { ...@@ -621,20 +623,12 @@ proc show_diff {path {w {}} {lno {}}} {
set is_3way_diff 0 set is_3way_diff 0
set diff_active 1 set diff_active 1
set current_diff_path $path set current_diff_path $path
set current_diff_side $w
set ui_status_value "Loading diff of [escape_path $path]..." set ui_status_value "Loading diff of [escape_path $path]..."
set cmd [list | git diff-index] # - Git won't give us the diff, there's nothing to compare to!
lappend cmd --no-color #
if {$repo_config(gui.diffcontext) > 0} { if {$m eq {_O}} {
lappend cmd "-U$repo_config(gui.diffcontext)"
}
lappend cmd -p
switch $m {
MM {
lappend cmd -c
}
_O {
if {[catch { if {[catch {
set fd [open $path r] set fd [open $path r]
set content [read $fd] set content [read $fd]
...@@ -654,9 +648,23 @@ proc show_diff {path {w {}} {lno {}}} { ...@@ -654,9 +648,23 @@ proc show_diff {path {w {}} {lno {}}} {
set ui_status_value {Ready.} set ui_status_value {Ready.}
return return
} }
set cmd [list | git]
if {$w eq $ui_index} {
lappend cmd diff-index
lappend cmd --cached
} elseif {$w eq $ui_workdir} {
lappend cmd diff-files
} }
lappend cmd [PARENT] lappend cmd -p
lappend cmd --no-color
if {$repo_config(gui.diffcontext) > 0} {
lappend cmd "-U$repo_config(gui.diffcontext)"
}
if {$w eq $ui_index} {
lappend cmd [PARENT]
}
lappend cmd -- lappend cmd --
lappend cmd $path lappend cmd $path
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册