[PATCH] git-gui: fix selection regression introduced in a8ca786991

Subsystems: library code, the rest

STALE3735d

3 messages, 1 author, 2016-06-15 · open the first message on its own page

[PATCH] git-gui: fix selection regression introduced in a8ca786991

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:52:44

While fixing the problem from a8ca786991, it introduces a regression
regarding what happen after the multi selected file operation (ie.
one of Ctrl-{T,U,J}) because the next selected file could not be handled
by such a subsequent file operation.

The right way is to move the fix from this commit down into the show_diff
function. So that all code path add the current diff path to the list of
selections.

This also simplifies helper functions for these operatione which needed
to handle the case whether there is only the current diff path or also
a selction.

Signed-off-by: Bert Wesarg <redacted>
---

I propbose this to be inlcuded in the next git-1.7.9 release.

 git-gui.sh    |    1 -
 lib/diff.tcl  |    3 ++-
 lib/index.tcl |   48 +++++++++++++++---------------------------------
 3 files changed, 17 insertions(+), 35 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index ba4e5c1..13b22dd 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2520,7 +2520,6 @@ proc toggle_or_diff {w x y} {
 				[concat $after [list ui_ready]]
 		}
 	} else {
-		set selected_paths($path) 1
 		show_diff $path $w $lno
 	}
 }
diff --git a/lib/diff.tcl b/lib/diff.tcl
index ec44055..775649c 100644
--- a/lib/diff.tcl
+++ b/lib/diff.tcl
@@ -75,7 +75,7 @@ A rescan will be automatically started to find other files which may have the sa
 }
 
 proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} {
-	global file_states file_lists
+	global file_states file_lists selected_paths
 	global is_3way_diff is_conflict_diff diff_active repo_config
 	global ui_diff ui_index ui_workdir
 	global current_diff_path current_diff_side current_diff_header
@@ -91,6 +91,7 @@ proc show_diff {path w {lno {}} {scroll_pos {}} {callback {}}} {
 		}
 	}
 	if {$lno >= 1} {
+		set selected_paths($path) 1
 		$w tag add in_diff $lno.0 [expr {$lno + 1}].0
 		$w see $lno.0
 	}
diff --git a/lib/index.tcl b/lib/index.tcl
index 8efbbdd..2223a21 100644
--- a/lib/index.tcl
+++ b/lib/index.tcl
@@ -287,17 +287,11 @@ proc unstage_helper {txt paths} {
 }
 
 proc do_unstage_selection {} {
-	global current_diff_path selected_paths
-
-	if {[array size selected_paths] > 0} {
-		unstage_helper \
-			{Unstaging selected files from commit} \
-			[array names selected_paths]
-	} elseif {$current_diff_path ne {}} {
-		unstage_helper \
-			[mc "Unstaging %s from commit" [short_path $current_diff_path]] \
-			[list $current_diff_path]
-	}
+	global selected_paths
+
+	unstage_helper \
+		{Unstaging selected files from commit} \
+		[array names selected_paths]
 }
 
 proc add_helper {txt paths} {
@@ -339,17 +333,11 @@ proc add_helper {txt paths} {
 }
 
 proc do_add_selection {} {
-	global current_diff_path selected_paths
-
-	if {[array size selected_paths] > 0} {
-		add_helper \
-			{Adding selected files} \
-			[array names selected_paths]
-	} elseif {$current_diff_path ne {}} {
-		add_helper \
-			[mc "Adding %s" [short_path $current_diff_path]] \
-			[list $current_diff_path]
-	}
+	global selected_paths
+
+	add_helper \
+		{Adding selected files} \
+		[array names selected_paths]
 }
 
 proc do_add_all {} {
@@ -452,17 +440,11 @@ proc revert_helper {txt paths} {
 }
 
 proc do_revert_selection {} {
-	global current_diff_path selected_paths
-
-	if {[array size selected_paths] > 0} {
-		revert_helper \
-			[mc "Reverting selected files"] \
-			[array names selected_paths]
-	} elseif {$current_diff_path ne {}} {
-		revert_helper \
-			[mc "Reverting %s" [short_path $current_diff_path]] \
-			[list $current_diff_path]
-	}
+	global selected_paths
+
+	revert_helper \
+		[mc "Reverting selected files"] \
+		[array names selected_paths]
 }
 
 proc do_select_commit_type {} {
-- 
1.7.8.1.873.gfea665

Re: [PATCH] git-gui: fix selection regression introduced in a8ca786991

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:52:45

Hi,

On Sat, Jan 7, 2012 at 20:43, Bert Wesarg [off-list ref] wrote:
While fixing the problem from a8ca786991, it introduces a regression
regarding what happen after the multi selected file operation (ie.
one of Ctrl-{T,U,J}) because the next selected file could not be handled
by such a subsequent file operation.

The right way is to move the fix from this commit down into the show_diff
function. So that all code path add the current diff path to the list of
selections.

This also simplifies helper functions for these operatione which needed
to handle the case whether there is only the current diff path or also
a selction.
I think we need to think this more through, especially with input from
Shawn, please.

I have now find out, that git-gui has two selections in the file
lists. The first is that for the current path for what we show the
diff (the tag for this is called 'in_diff') and the the second is that
for the current list of paths which are selected ('in_sel'). The file
list operations 'staging', 'reverting', 'unstaging', work either on
'in_sel'; if that is not empty, or on 'in_diff'. The problem I've now
realized is, that these two selections share the same visual hints,
ie. a lightgray background.

The problem I tried to solve in a8ca786991 was, that adding paths to
the selection with Ctrl-Button-1 or Shift-cutton-1, didn't included
the current diff path in the subsequent file list operation. But I
would have expected it, because it was visual in the 'selection'.

My current 'workaround' is to make the two selections visually
distinguishable (and reverting a8ca786991), by using a different
background color for the 'in_sel' tag and also the italic font, so
that it is still possible to see whether the current diff path is in
the selection or not:
@@ -717,11 +717,11 @@ proc tk_optionMenu {w varName args} {
 proc rmsel_tag {text} {
 	$text tag conf sel \
 		-background [$text cget -background] \
 		-foreground [$text cget -foreground] \
 		-borderwidth 0
-	$text tag conf in_sel -background lightgray
+	$text tag conf in_sel -background SlateGray1 -font font_diffitalic
 	bind $text <Motion> break
 	return $text
 }

 wm withdraw .
@@ -3557,11 +3557,11 @@ if {$use_ttk} {
 	.vpane.files add .vpane.files.index -sticky news
 }

 foreach i [list $ui_index $ui_workdir] {
 	rmsel_tag $i
-	$i tag conf in_diff -background [$i tag cget in_sel -background]
+	$i tag conf in_diff -background lightgray
 }
 unset i

 set files_ctxm .vpane.files.ctxm
 menu $files_ctxm -tearoff 0
I'm not very pleased with this, but at least it is now possible to
visual recognize what files will be handled by a subsequent file list
operation.

Any input is more than welcome.

Regards,
Bert

Re: [PATCH] git-gui: fix selection regression introduced in a8ca786991

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:52:48

Hi Pat,

On Mon, Jan 9, 2012 at 10:28, Bert Wesarg [off-list ref] wrote:
quoted hunk
Hi,

On Sat, Jan 7, 2012 at 20:43, Bert Wesarg [off-list ref] wrote:
quoted
While fixing the problem from a8ca786991, it introduces a regression
regarding what happen after the multi selected file operation (ie.
one of Ctrl-{T,U,J}) because the next selected file could not be handled
by such a subsequent file operation.

The right way is to move the fix from this commit down into the show_diff
function. So that all code path add the current diff path to the list of
selections.

This also simplifies helper functions for these operatione which needed
to handle the case whether there is only the current diff path or also
a selction.
I think we need to think this more through, especially with input from
Shawn, please.

I have now find out, that git-gui has two selections in the file
lists. The first is that for the current path for what we show the
diff (the tag for this is called 'in_diff') and the the second is that
for the current list of paths which are selected ('in_sel'). The file
list operations 'staging', 'reverting', 'unstaging', work either on
'in_sel'; if that is not empty, or on 'in_diff'. The problem I've now
realized is, that these two selections share the same visual hints,
ie. a lightgray background.

The problem I tried to solve in a8ca786991 was, that adding paths to
the selection with Ctrl-Button-1 or Shift-cutton-1, didn't included
the current diff path in the subsequent file list operation. But I
would have expected it, because it was visual in the 'selection'.

My current 'workaround' is to make the two selections visually
distinguishable (and reverting a8ca786991), by using a different
background color for the 'in_sel' tag and also the italic font, so
that it is still possible to see whether the current diff path is in
the selection or not:
@@ -717,11 +717,11 @@ proc tk_optionMenu {w varName args} {
 proc rmsel_tag {text} {
       $text tag conf sel \
               -background [$text cget -background] \
               -foreground [$text cget -foreground] \
               -borderwidth 0
-       $text tag conf in_sel -background lightgray
+       $text tag conf in_sel -background SlateGray1 -font font_diffitalic
       bind $text <Motion> break
       return $text
 }

 wm withdraw .
@@ -3557,11 +3557,11 @@ if {$use_ttk} {
       .vpane.files add .vpane.files.index -sticky news
 }

 foreach i [list $ui_index $ui_workdir] {
       rmsel_tag $i
-       $i tag conf in_diff -background [$i tag cget in_sel -background]
+       $i tag conf in_diff -background lightgray
 }
 unset i

 set files_ctxm .vpane.files.ctxm
 menu $files_ctxm -tearoff 0

I'm not very pleased with this, but at least it is now possible to
visual recognize what files will be handled by a subsequent file list
operation.

Any input is more than welcome.
I think we don't resolve this now, because a8ca786991 introduced a
regression introduced in 0.16, I propose to revert it for upcoming
1.7.9 release.

Thanks.

Bert
Regards,
Bert
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help