git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Jan 7, 2012, 19:43 UTC
Message-ID
<14628854a651ab0202e3f82be9b245331cf9029a.1325965254.git.bert.wesarg@googlemail.com>

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
Next: Bert Wesarg
Message 1 of 3 in “git-gui: fix selection regression introduced in a8ca786991”
  1. git-gui: fix selection regression introduced in a8ca786991Bert Wesarg, Jan 7, 2012
  2. Bert WesargJan 9, 2012
  3. Bert WesargJan 14, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.