Allow git-runstatus to limit its scope to a set of files/directories.
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 Allow git-runstatus to limit its scope to a set of files/directories.
---
IMO, the next step should be to tweak git-status/git-commit: I suggest introducing a new option '--what-if' to 'git-commit' that behaves like current 'git-status [<path>...]' and in return stop 'git-status' from displaying '[<path>...]' as "Changes to commit".
Documentation/git-runstatus.txt | 6 +++++- builtin-runstatus.c | 5 ++++- wt-status.c | 13 ++++++++++++- wt-status.h | 1 + 4 files changed, 22 insertions(+), 3 deletions(-)
Documentation/git-runstatus.txt +5 -1
@@ -8,7 +8,7 @@ git-runstatus - A helper for git-status and git-commit SYNOPSIS -------- -'git-runstatus' [--color|--nocolor] [--amend] [--verbose] [--untracked] +'git-runstatus' [--color|--nocolor] [--amend] [--verbose] [--untracked] [<path>...] DESCRIPTION
@@ -47,6 +47,10 @@ OPTIONS option only its name and a trailing slash are displayed for each untracked directory. +<path>...:: + The <path> parameters, when given, are used to limit + the status to the named path(s). + OUTPUT ------
builtin-runstatus.c +4 -1
@@ -5,7 +5,7 @@extern int wt_status_use_color;static const char runstatus_usage[] = -"git-runstatus [--color|--nocolor] [--amend] [--verbose] [--untracked]" ; +"git-runstatus [--color|--nocolor] [--amend] [--verbose] [--untracked] [<path>...]" ;int cmd_runstatus (int argc,const char **argv,const char *prefix) {
@@ -16,6 +16,8 @@ int cmd_runstatus(int argc, const char **argv, const char *prefix)wt_status_prepare (&s);for (i =1 ; i < argc; i++) { +if (argv[i][0 ] !='-' ) +break ;if (!strcmp (argv[i],"--color" )) wt_status_use_color =1 ;else if (!strcmp (argv[i],"--nocolor" ))
@@ -32,6 +34,7 @@ int cmd_runstatus(int argc, const char **argv, const char *prefix)usage (runstatus_usage); } + s.pathspec = argc > i ?get_pathspec (prefix, argv+i) :NULL ;wt_status_print (&s);return s.commitable ?0 :1 ; }
wt-status.c +12 -1
@@ -228,6 +228,7 @@ static void wt_status_print_updated(struct wt_status *s) rev.diffopt.format_callback_data = s; rev.diffopt.detect_rename =1 ; rev.diffopt.rename_limit =100 ; + rev.prune_data = s->pathspec;wt_read_cache (s);run_diff_index (&rev,1 ); }
@@ -240,6 +241,7 @@ static void wt_status_print_changed(struct wt_status *s) rev.diffopt.output_format |=DIFF_FORMAT_CALLBACK ; rev.diffopt.format_callback = wt_status_print_changed_cb; rev.diffopt.format_callback_data = s; + rev.prune_data = s->pathspec;wt_read_cache (s);run_diff_files (&rev,0 ); }
@@ -248,7 +250,8 @@ static void wt_status_print_untracked(struct wt_status *s) {struct dir_struct dir;const char *x; -int i; +int i, specs; +char *seen;int shown_header =0 ;memset (&dir,0 ,sizeof (dir));
@@ -264,11 +267,19 @@ static void wt_status_print_untracked(struct wt_status *s)if (excludes_file &&file_exists (excludes_file))add_excludes_from_file (&dir, excludes_file); +for (specs =0 ; s->pathspec && s->pathspec[specs]; specs++) +/* nothing */ ; +if (specs) + seen =xcalloc (specs,1 ); +read_directory (&dir,"." ,"" ,0 ,NULL );for (i =0 ; i < dir.nr; i++) {/* check for matching entry, which is unmerged; lifted from * builtin-ls-files:show_other_files */ struct dir_entry *ent = dir.entries[i]; +if (specs && + !match_pathspec (s->pathspec, ent->name, ent->len,0 , seen)) +continue ;int pos =cache_name_pos (ent->name, ent->len);struct cache_entry *ce;if (0 <= pos)
wt-status.h +1 -0
@@ -15,6 +15,7 @@ struct wt_status {int verbose;int amend;int untracked; +const char **pathspec;/* These are computed during processing of the individual sections */ int commitable;int workdir_dirty;
Signature · 1 line
1.5.3.4.316.g8a37e
Hi,
Quoted 6 lines · Michel Marti
Signed-off-by Michel Marti <[email protected]>---
IMO, the next step should be to tweak git-status/git-commit: I suggest introducing a new option '--what-if' to 'git-commit' that behaves like current 'git-status [<path>...]' and in return stop 'git-status' from displaying '[<path>...]' as "Changes to commit".
I am not sure this is the correct way to go, since "git status" as a "git commit --dry-run" has worked well so far.
Besides, I would like to see builtin-commit go in as soon as possible, and this patch would delay that.
Ciao,
Dscho
Quoted 8 lines · Johannes Schindelin
Quoted 4 lines · Michel Marti
Signed-off-by Michel Marti <[email protected]>---
IMO, the next step should be to tweak git-status/git-commit: I suggest introducing a new option '--what-if' to 'git-commit' that behaves like current 'git-status [<path>...]' and in return stop 'git-status' from displaying '[<path>...]' as "Changes to commit".I am not sure this is the correct way to go, since "git status" as a "git commit --dry-run" has worked well so far.
Maybe, but current git-status behaviour is somewhat illogical and I'm pretty sure there are more than a few git-users that were puzzled after calling "git-status some-dir" for the first time.
Quoted 1 line
Besides, I would like to see builtin-commit go in as soon as possible, and this patch would delay that.
Hmmm, why is that? The patch only touches git-runstatus, invoking "git-status <path>" will behave as usual.
- Michel