summaryrefslogtreecommitdiff
path: root/git-gui.sh
diff options
context:
space:
mode:
authorLibravatar Johannes Sixt <johannes.sixt@telecom.at>2008-06-27 09:22:01 +0200
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2008-07-02 01:06:38 -0400
commit5821988f97b827f6ba81dfeebff932067c88ba6c (patch)
treef12d10aef8c33298e95b6a7234d7732509833571 /git-gui.sh
parentgit-gui: Don't select the wrong file if the last listed file is staged. (diff)
downloadtgif-5821988f97b827f6ba81dfeebff932067c88ba6c.tar.xz
git-gui: Implement "Stage/Unstage Line"
This adds a context menu entry below "Stage/Unstage Hunk" that stages or unstages just the line under the mouse pointer. This is by itself useful, for example, if there are unrelated changes in the same hunk and the hunk cannot be split by reducing the context. The feature can also be used to split a hunk by staging a number of additions (or unstaging a number of removals) until there are enough context lines that the hunk gets split. The implementation reads the complete hunk that the line lives in, and constructs a new hunk by picking existing context lines, removing unneeded change lines and transforming other change lines to context lines. The resulting hunk is fed through 'git apply' just like in the "Stage/Unstage Hunk" case. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'git-gui.sh')
-rwxr-xr-xgit-gui.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 1bbae15a50..d89f156fd5 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2666,6 +2666,11 @@ $ctxm add command \
-command {apply_hunk $cursorX $cursorY}
set ui_diff_applyhunk [$ctxm index last]
lappend diff_actions [list $ctxm entryconf $ui_diff_applyhunk -state]
+$ctxm add command \
+ -label [mc "Apply/Reverse Line"] \
+ -command {apply_line $cursorX $cursorY; do_rescan}
+set ui_diff_applyline [$ctxm index last]
+lappend diff_actions [list $ctxm entryconf $ui_diff_applyline -state]
$ctxm add separator
$ctxm add command \
-label [mc "Show Less Context"] \
@@ -2714,8 +2719,10 @@ proc popup_diff_menu {ctxm x y X Y} {
set ::cursorY $y
if {$::ui_index eq $::current_diff_side} {
set l [mc "Unstage Hunk From Commit"]
+ set t [mc "Unstage Line From Commit"]
} else {
set l [mc "Stage Hunk For Commit"]
+ set t [mc "Stage Line For Commit"]
}
if {$::is_3way_diff
|| $current_diff_path eq {}
@@ -2726,6 +2733,7 @@ proc popup_diff_menu {ctxm x y X Y} {
set s normal
}
$ctxm entryconf $::ui_diff_applyhunk -state $s -label $l
+ $ctxm entryconf $::ui_diff_applyline -state $s -label $t
tk_popup $ctxm $X $Y
}
bind_button3 $ui_diff [list popup_diff_menu $ctxm %x %y %X %Y]