git-gui: Add menu option to include only selected files.
When the user selects a number of files they would typically expect to be able to act on that selection, such as by including those files into the next commit. So we now have a menu option under the Commit menu that lets the user include only the selection, rather than everything. If there is no selection but there is a file in the diff viewer than we consider that to be the selection (a selection of 1). Unfortunately we don't disable this option yet when there's nothing selected to include, but this is probably not a big deal as there are very few situations where there are no selected files. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Nov 18, 2006 at 03:24 UTC
c4ed879fc2b64b6c6f8a42bd156b2e4bd18e9420
1 file changed
+29
-3
git-gui
+29
-3
@@ -1853,14 +1853,14 @@ proc do_rescan {} {
1853
rescan {set ui_status_value {Ready.}}
1854
}
1855
1856
-proc do_include_all {} {
1856
+proc include_helper {txt paths} {
1857
global file_states current_diff
1858
1859
if {![lock_index begin-update]} return
1860
1861
set pathList [list]
1862
set after {}
1863
- foreach path [array names file_states] {
1863
+ foreach path $paths {
1864
switch -- [lindex $file_states($path) 0] {
1865
AM -
1866
MM -
@@ -1877,12 +1877,33 @@ proc do_include_all {} {
1877
unlock_index
1878
} else {
1879
update_index \
1880
- "Including all modified files" \
1880
+ $txt \
1881
$pathList \
1882
[concat $after {set ui_status_value {Ready to commit.}}]
1883
}
1884
}
1885
1886
+proc do_include_selection {} {
1887
+ global current_diff selected_paths
1888
+
1889
+ if {[array size selected_paths] > 0} {
1890
+ include_helper \
1891
+ {Including selected files} \
1892
+ [array names selected_paths]
1893
+ } elseif {$current_diff ne {}} {
1894
+ include_helper \
1895
+ "Including [short_path $current_diff]" \
1896
+ [list $current_diff]
1897
+ }
1898
+}
1899
+
1900
+proc do_include_all {} {
1901
+ global file_states
1902
+ include_helper \
1903
+ {Including all modified files} \
1904
+ [array names file_states]
1905
+}
1906
+
1907
set GIT_COMMITTER_IDENT {}
1908
1909
proc do_signoff {} {
@@ -2442,6 +2463,11 @@ lappend disable_on_lock \
2463
-font font_ui
2464
lappend disable_on_lock \
2465
[list .mbar.commit entryconf [.mbar.commit index last] -state]
2466
+.mbar.commit add command -label {Include Selected Files} \
2467
+ -command do_include_selection \
2468
+ -font font_ui
2469
+lappend disable_on_lock \
2470
+ [list .mbar.commit entryconf [.mbar.commit index last] -state]
2471
.mbar.commit add command -label {Include All Files} \
2472
-command do_include_all \
2473
-accelerator $M1T-I \