git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-gui: fix selection regression introduced in a8ca786991
@ 2012-01-07 19:43 Bert Wesarg
  2012-01-09  9:28 ` Bert Wesarg
  0 siblings, 1 reply; 3+ messages in thread
From: Bert Wesarg @ 2012-01-07 19:43 UTC (permalink / raw)
  To: Pat Thoyts; +Cc: git, Bert Wesarg

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 <bert.wesarg@googlemail.com>
---

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-gui: fix selection regression introduced in a8ca786991
  2012-01-07 19:43 [PATCH] git-gui: fix selection regression introduced in a8ca786991 Bert Wesarg
@ 2012-01-09  9:28 ` Bert Wesarg
  2012-01-14 11:58   ` Bert Wesarg
  0 siblings, 1 reply; 3+ messages in thread
From: Bert Wesarg @ 2012-01-09  9:28 UTC (permalink / raw)
  To: Pat Thoyts; +Cc: git, Bert Wesarg, Shawn O. Pearce

Hi,

On Sat, Jan 7, 2012 at 20:43, Bert Wesarg <bert.wesarg@googlemail.com> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-gui: fix selection regression introduced in a8ca786991
  2012-01-09  9:28 ` Bert Wesarg
@ 2012-01-14 11:58   ` Bert Wesarg
  0 siblings, 0 replies; 3+ messages in thread
From: Bert Wesarg @ 2012-01-14 11:58 UTC (permalink / raw)
  To: Pat Thoyts; +Cc: git, Bert Wesarg, Shawn O. Pearce

Hi Pat,

On Mon, Jan 9, 2012 at 10:28, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> Hi,
>
> On Sat, Jan 7, 2012 at 20:43, Bert Wesarg <bert.wesarg@googlemail.com> 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.
>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-01-14 11:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-07 19:43 [PATCH] git-gui: fix selection regression introduced in a8ca786991 Bert Wesarg
2012-01-09  9:28 ` Bert Wesarg
2012-01-14 11:58   ` Bert Wesarg

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).