From: Alexander Gavrilov <angavrilov@gmail.com>
To: git@vger.kernel.org
Cc: "Shawn O. Pearce" <spearce@spearce.org>
Subject: [PATCH (GIT-GUI) 8/8] git-gui: Show special diffs for complex conflict cases.
Date: Sun, 31 Aug 2008 01:05:22 +0400 [thread overview]
Message-ID: <200808310105.23106.angavrilov@gmail.com> (raw)
In-Reply-To: <200808310104.11048.angavrilov@gmail.com>
Add special handling for displaying diffs of modified/deleted,
and symlink/mode conflicts. Currently the display is completely
unusable for deciding how to resolve the conflict.
New display modes:
1) Deleted/Modified conflict: e.g.
LOCAL: deleted
REMOTE:
[diff :1:$path :3:$path]
2) Conflict involving symlinks:
LOCAL:
[diff :1:$path :2:$path]
REMOTE:
[diff :1:$path :3:$path]
In order to be able to display multiple diffs, this
patch adds a queue of commands to call.
Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
lib/diff.tcl | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 89 insertions(+), 5 deletions(-)
diff --git a/lib/diff.tcl b/lib/diff.tcl
index 95998b4..c67b020 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -65,6 +65,7 @@ proc show_diff {path w {lno {}} {scroll_pos {}}} {
global is_3way_diff diff_active repo_config
global ui_diff ui_index ui_workdir
global current_diff_path current_diff_side current_diff_header
+ global current_diff_queue
if {$diff_active || ![lock_index read]} return
@@ -82,13 +83,69 @@ proc show_diff {path w {lno {}} {scroll_pos {}}} {
set s $file_states($path)
set m [lindex $s 0]
- set is_3way_diff 0
- set diff_active 1
set current_diff_path $path
set current_diff_side $w
- set current_diff_header {}
+ set current_diff_queue {}
ui_status [mc "Loading diff of %s..." [escape_path $path]]
+ if {[string first {U} $m] >= 0} {
+ merge_load_stages $path [list show_unmerged_diff $scroll_pos]
+ } elseif {$m eq {_O}} {
+ show_other_diff $path $w $m $scroll_pos
+ } else {
+ start_show_diff $scroll_pos
+ }
+}
+
+proc show_unmerged_diff {scroll_pos} {
+ global current_diff_path current_diff_side
+ global merge_stages ui_diff
+ global current_diff_queue
+
+ if {$merge_stages(2) eq {}} {
+ lappend current_diff_queue \
+ [list "LOCAL: deleted\nREMOTE:\n" d======= \
+ [list ":1:$current_diff_path" ":3:$current_diff_path"]]
+ } elseif {$merge_stages(3) eq {}} {
+ lappend current_diff_queue \
+ [list "REMOTE: deleted\nLOCAL:\n" d======= \
+ [list ":1:$current_diff_path" ":2:$current_diff_path"]]
+ } elseif {[lindex $merge_stages(1) 0] eq {120000}
+ || [lindex $merge_stages(2) 0] eq {120000}
+ || [lindex $merge_stages(3) 0] eq {120000}} {
+ lappend current_diff_queue \
+ [list "LOCAL:\n" d======= \
+ [list ":1:$current_diff_path" ":2:$current_diff_path"]]
+ lappend current_diff_queue \
+ [list "REMOTE:\n" d======= \
+ [list ":1:$current_diff_path" ":3:$current_diff_path"]]
+ } else {
+ start_show_diff $scroll_pos
+ return
+ }
+
+ advance_diff_queue $scroll_pos
+}
+
+proc advance_diff_queue {scroll_pos} {
+ global current_diff_queue ui_diff
+
+ set item [lindex $current_diff_queue 0]
+ set current_diff_queue [lrange $current_diff_queue 1 end]
+
+ $ui_diff conf -state normal
+ $ui_diff insert end [lindex $item 0] [lindex $item 1]
+ $ui_diff conf -state disabled
+
+ start_show_diff $scroll_pos [lindex $item 2]
+}
+
+proc show_other_diff {path w m scroll_pos} {
+ global file_states file_lists
+ global is_3way_diff diff_active repo_config
+ global ui_diff ui_index ui_workdir
+ global current_diff_path current_diff_side current_diff_header
+
# - Git won't give us the diff, there's nothing to compare to!
#
if {$m eq {_O}} {
@@ -167,6 +224,22 @@ proc show_diff {path w {lno {}} {scroll_pos {}}} {
ui_ready
return
}
+}
+
+proc start_show_diff {scroll_pos {add_opts {}}} {
+ global file_states file_lists
+ global is_3way_diff diff_active repo_config
+ global ui_diff ui_index ui_workdir
+ global current_diff_path current_diff_side current_diff_header
+
+ set path $current_diff_path
+ set w $current_diff_side
+
+ set s $file_states($path)
+ set m [lindex $s 0]
+ set is_3way_diff 0
+ set diff_active 1
+ set current_diff_header {}
set cmd [list]
if {$w eq $ui_index} {
@@ -188,8 +261,12 @@ proc show_diff {path w {lno {}} {scroll_pos {}}} {
if {$w eq $ui_index} {
lappend cmd [PARENT]
}
- lappend cmd --
- lappend cmd $path
+ if {$add_opts ne {}} {
+ eval lappend cmd $add_opts
+ } else {
+ lappend cmd --
+ lappend cmd $path
+ }
if {[catch {set fd [eval git_read --nice $cmd]} err]} {
set diff_active 0
@@ -209,6 +286,7 @@ proc show_diff {path w {lno {}} {scroll_pos {}}} {
proc read_diff {fd scroll_pos} {
global ui_diff diff_active
global is_3way_diff current_diff_header
+ global current_diff_queue
$ui_diff conf -state normal
while {[gets $fd line] >= 0} {
@@ -293,6 +371,12 @@ proc read_diff {fd scroll_pos} {
if {[eof $fd]} {
close $fd
+
+ if {$current_diff_queue ne {}} {
+ advance_diff_queue $scroll_pos
+ return
+ }
+
set diff_active 0
unlock_index
if {$scroll_pos ne {}} {
--
1.6.0.20.g6148bc
next prev parent reply other threads:[~2008-08-30 21:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-30 20:52 [PATCH (GIT-GUI) 0/8] Add mergetool functionality to git-gui Alexander Gavrilov
2008-08-30 20:54 ` [PATCH (GIT-GUI) 1/8] git-gui: Don't allow staging files with conflicts Alexander Gavrilov
2008-08-30 20:55 ` [PATCH (GIT-GUI) 2/8] git-gui: Support resolving conflicts via the diff context menu Alexander Gavrilov
2008-08-30 20:56 ` [PATCH (GIT-GUI) 3/8] git-gui: Support calling merge tools Alexander Gavrilov
2008-08-30 20:59 ` [PATCH (GIT-GUI) 4/8] git-gui: Support more " Alexander Gavrilov
2008-08-30 21:00 ` [PATCH (GIT-GUI) 5/8] git-gui: Support conflict states _U & UT Alexander Gavrilov
2008-08-30 21:02 ` [PATCH (GIT-GUI) 6/8] git-gui: Reimplement and enhance auto-selection of diffs Alexander Gavrilov
2008-08-30 21:04 ` [PATCH (GIT-GUI) 7/8] git-gui: Make F5 reselect a diff, if an untracked file is selected Alexander Gavrilov
2008-08-30 21:05 ` Alexander Gavrilov [this message]
2008-09-08 12:10 ` [PATCH (GIT-GUI) 1/8] git-gui: Don't allow staging files with conflicts Johannes Sixt
2008-09-08 12:25 ` Alexander Gavrilov
2008-09-17 11:40 ` [PATCH/RFC 0/2] git-gui: issues with merge tool series Johannes Sixt
2008-09-17 11:40 ` [PATCH/RFC 1/2] Revert "git-gui: Don't allow staging files with conflicts." Johannes Sixt
2008-09-17 11:40 ` [PATCH/RFC 2/2] git-gui: Do not automatically stage file after merge tool finishes Johannes Sixt
2008-09-17 12:25 ` Alexander Gavrilov
2008-09-24 17:50 ` Shawn O. Pearce
2008-09-24 19:08 ` [PATCH/RFC 2/2 v2] " Johannes Sixt
2008-09-17 12:50 ` [PATCH/RFC 0/2] git-gui: issues with merge tool series Alexander Gavrilov
2008-09-17 21:40 ` Johannes Sixt
2008-09-17 22:24 ` Alexander Gavrilov
2008-09-24 17:48 ` Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200808310105.23106.angavrilov@gmail.com \
--to=angavrilov@gmail.com \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).