1111 * GNU General Public License for more details.
1212 */
1313
14+ #include "tig/argv.h"
1415#include "tig/io.h"
1516#include "tig/refdb.h"
1617#include "tig/repo.h"
@@ -92,8 +93,14 @@ status_run(struct view *view, const char *argv[], char status, enum line_type ty
9293 struct buffer buf ;
9394 struct io io ;
9495 const char * * status_argv = NULL ;
95- bool ok = argv_format (view -> env , & status_argv , argv , 0 ) &&
96- io_run (& io , IO_RD , repo .exec_dir , NULL , status_argv );
96+ int format_flags = 0 ;
97+ bool ok ;
98+
99+ if (!view_has_flags (view , VIEW_FILE_FILTER ) || opt_file_filter )
100+ format_flags |= argv_flag_file_filter ;
101+
102+ ok = argv_format (view -> env , & status_argv , argv , format_flags ) &&
103+ io_run (& io , IO_RD , repo .exec_dir , NULL , status_argv );
97104
98105 argv_free (status_argv );
99106 free (status_argv );
@@ -188,12 +195,8 @@ status_run(struct view *view, const char *argv[], char status, enum line_type ty
188195static const char * status_diff_index_argv [] = { GIT_DIFF_STAGED_FILES ("-z" ) };
189196static const char * status_diff_files_argv [] = { GIT_DIFF_UNSTAGED_FILES ("-z" ) };
190197
191- static const char * status_list_other_argv [] = {
192- "git" , "ls-files" , "-z" , "--others" , "--exclude-standard" , NULL , NULL , NULL
193- };
194-
195198static const char * status_list_no_head_argv [] = {
196- "git" , "ls-files" , "-z" , "--cached" , "--exclude-standard" , NULL
199+ "git" , "ls-files" , "-z" , "--cached" , "--exclude-standard" , "%(fileargs)" , NULL
197200};
198201
199202/* Restore the previous line number to stay in the context or select a
@@ -361,16 +364,26 @@ status_update_onbranch(void)
361364static bool
362365status_read_untracked (struct view * view )
363366{
367+ const char * argv [16 ];
368+ int argc = 0 ;
369+
364370 if (!opt_status_show_untracked_files )
365371 return add_line_nodata (view , LINE_STAT_UNTRACKED )
366372 && add_line_nodata (view , LINE_STAT_NONE );
367373
368- status_list_other_argv [ARRAY_SIZE (status_list_other_argv ) - 3 ] =
369- opt_status_show_untracked_dirs ? NULL : "--directory" ;
370- status_list_other_argv [ARRAY_SIZE (status_list_other_argv ) - 2 ] =
371- opt_status_show_untracked_dirs ? NULL : "--no-empty-directory" ;
374+ argv [argc ++ ] = "git" ;
375+ argv [argc ++ ] = "ls-files" ;
376+ argv [argc ++ ] = "-z" ;
377+ argv [argc ++ ] = "--others" ;
378+ argv [argc ++ ] = "--exclude-standard" ;
379+ if (!opt_status_show_untracked_dirs ) {
380+ argv [argc ++ ] = "--directory" ;
381+ argv [argc ++ ] = "--no-empty-directory" ;
382+ }
383+ argv [argc ++ ] = "%(fileargs)" ;
384+ argv [argc ] = NULL ;
372385
373- return status_run (view , status_list_other_argv , '?' , LINE_STAT_UNTRACKED );
386+ return status_run (view , argv , '?' , LINE_STAT_UNTRACKED );
374387}
375388
376389/* First parse staged info using git-diff-index(1), then parse unstaged
@@ -394,7 +407,8 @@ status_open(struct view *view, enum open_flags flags)
394407 add_line_nodata (view , LINE_HEADER );
395408 status_update_onbranch ();
396409
397- update_index ();
410+ if (!opt_file_args || !opt_file_filter )
411+ update_index ();
398412
399413 if ((!show_untracked_only && !status_run (view , staged_argv , staged_status , LINE_STAT_STAGED )) ||
400414 (!show_untracked_only && !status_run (view , status_diff_files_argv , 0 , LINE_STAT_UNSTAGED )) ||
@@ -865,7 +879,7 @@ status_select(struct view *view, struct line *line)
865879static struct view_ops status_ops = {
866880 "file" ,
867881 "" ,
868- VIEW_CUSTOM_STATUS | VIEW_SEND_CHILD_ENTER | VIEW_STATUS_LIKE | VIEW_REFRESH ,
882+ VIEW_CUSTOM_STATUS | VIEW_SEND_CHILD_ENTER | VIEW_STATUS_LIKE | VIEW_FILE_FILTER | VIEW_REFRESH ,
869883 0 ,
870884 status_open ,
871885 NULL ,
0 commit comments