All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] git-gui: Fast staging/unstaging of hunks/lines
@ 2010-04-05  9:01 Bert Wesarg
  2010-04-11  7:38 ` Bert Wesarg
  0 siblings, 1 reply; 6+ messages in thread
From: Bert Wesarg @ 2010-04-05  9:01 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, Bert Wesarg

This adds a shortcut to stage/unstage hunks or a range of lines. Which is done
on a mouse button 1 release event and holding the control key in the diff view.
If there is currently a selection only the selected lines will be staged/unstaged.
Otherwise the hunk will be staged/unstaged.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 git-gui/git-gui.sh |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 7d54511..e65a0e6 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -3452,6 +3452,22 @@ proc popup_diff_menu {ctxm ctxmmg ctxmsm x y X Y} {
 }
 bind_button3 $ui_diff [list popup_diff_menu $ctxm $ctxmmg $ctxmsm %x %y %X %Y]
 
+# applies/reverses hunks or lines on button-1 release
+proc immediate_apply_hunk_or_lines {x y} {
+	global current_diff_path file_states
+	set ::cursorX $x
+	set ::cursorY $y
+
+	set has_range [expr {[$::ui_diff tag nextrange sel 0.0] != {}}]
+	if {$has_range} {
+		apply_range_or_line $::cursorX $:cursorY
+		do_rescan
+	} else {
+		apply_hunk $::cursorX $::cursorY
+	}
+}
+bind $ui_diff <$M1B-ButtonRelease-1> {immediate_apply_hunk_or_lines %x %y}
+
 # -- Status Bar
 #
 set main_status [::status_bar::new .status]
-- 
1.7.0.3.418.gf56ac.dirty

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

end of thread, other threads:[~2010-04-12 17:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-05  9:01 [PATCH] git-gui: Fast staging/unstaging of hunks/lines Bert Wesarg
2010-04-11  7:38 ` Bert Wesarg
2010-04-11 19:01   ` Johannes Sixt
2010-04-12  6:49     ` Bert Wesarg
2010-04-12 17:45       ` Johannes Sixt
2010-04-12 17:55         ` Bert Wesarg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.