aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2008-08-31 01:04:10 +0400
committerShawn O. Pearce <spearce@spearce.org>2008-09-04 21:28:55 -0700
commit8056cc4f293b5e2bf0520f085e25b127c2ef3bbf (patch)
tree1c5c85230ae686db9b4a3bc2e7dac0734618bb8a
parent29853b901045ff09ac8e5b48a01ebbc96fa4874d (diff)
downloadgit-8056cc4f293b5e2bf0520f085e25b127c2ef3bbf.tar.gz
git-8056cc4f293b5e2bf0520f085e25b127c2ef3bbf.tar.xz
git-gui: Make F5 reselect a diff, if an untracked file is selected.
If an untracked file is selected, F5 and other manual rescan synonyms would try to select a tracked file instead. Also, clicking on an icon in the unstaged changes list skips over untracked files, unless the file clicked is untracked itself. The objective is to make it easier to ignore untracked files showing up in the Unstaged Changes list, and ensure that no modifications to tracked objects are left unstaged. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rwxr-xr-xgit-gui.sh44
1 files changed, 35 insertions, 9 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 74e0a7bca..10d8a4422 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1817,6 +1817,10 @@ proc do_rescan {} {
rescan ui_ready
}
+proc ui_do_rescan {} {
+ rescan {force_first_diff; ui_ready}
+}
+
proc do_commit {} {
commit_tree
}
@@ -1917,6 +1921,18 @@ proc select_first_diff {} {
}
}
+proc force_first_diff {} {
+ global current_diff_path
+
+ if {[info exists file_states($current_diff_path)]} {
+ set state [lindex $file_states($current_diff_path) 0]
+
+ if {[string index $state 1] ne {O}} return
+ }
+
+ select_first_diff
+}
+
proc toggle_or_diff {w x y} {
global file_states file_lists current_diff_path ui_index ui_workdir
global last_clicked selected_paths
@@ -1938,13 +1954,23 @@ proc toggle_or_diff {w x y} {
# Do not stage files with conflicts
if {[info exists file_states($path)]} {
set state [lindex $file_states($path) 0]
- if {[string first {U} $state] >= 0} {
- set col 1
- }
+ } else {
+ set state {__}
+ }
+
+ if {[string first {U} $state] >= 0} {
+ set col 1
}
+ # Restage the file, or simply show the diff
if {$col == 0 && $y > 1} {
- set after [next_diff_after_action $w $path $lno]
+ if {[string index $state 1] eq {O}} {
+ set mmask {}
+ } else {
+ set mmask {[^O]}
+ }
+
+ set after [next_diff_after_action $w $path $lno $mmask]
if {$w eq $ui_index} {
update_indexinfo \
@@ -2208,7 +2234,7 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
.mbar.commit add separator
.mbar.commit add command -label [mc Rescan] \
- -command do_rescan \
+ -command ui_do_rescan \
-accelerator F5
lappend disable_on_lock \
[list .mbar.commit entryconf [.mbar.commit index last] -state]
@@ -2564,7 +2590,7 @@ pack .vpane.lower.commarea.buttons.l -side top -fill x
pack .vpane.lower.commarea.buttons -side left -fill y
button .vpane.lower.commarea.buttons.rescan -text [mc Rescan] \
- -command do_rescan
+ -command ui_do_rescan
pack .vpane.lower.commarea.buttons.rescan -side top -fill x
lappend disable_on_lock \
{.vpane.lower.commarea.buttons.rescan conf -state}
@@ -2985,9 +3011,9 @@ if {[is_enabled transport]} {
bind . <$M1B-Key-P> do_push_anywhere
}
-bind . <Key-F5> do_rescan
-bind . <$M1B-Key-r> do_rescan
-bind . <$M1B-Key-R> do_rescan
+bind . <Key-F5> ui_do_rescan
+bind . <$M1B-Key-r> ui_do_rescan
+bind . <$M1B-Key-R> ui_do_rescan
bind . <$M1B-Key-s> do_signoff
bind . <$M1B-Key-S> do_signoff
bind . <$M1B-Key-t> do_add_selection