{"thread":{"id":"10492","subject":"[PATCH] Allow git-runstatus to limit its scope to a set of files/directories.","startedAt":"2007-10-27T18:08:39Z","lastAt":"2007-10-27T18:44:57Z","messageCount":3,"participants":["Michel Marti","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"57370","messageId":"1193508519-14140-1-git-send-email-mma@objectxp.com","threadId":"10492","inReplyTo":"ffofbm@ger.gmane.org","subject":"[PATCH] Allow git-runstatus to limit its scope to a set of files/directories.","fromName":"Michel Marti","fromEmail":"mma@objectxp.com","sentAt":"2007-10-27T18:08:39Z","receivedAt":"2007-10-27T18:08:39Z","isPatch":true,"sender":{"key":"mma@objectxp.com","avatar":null},"body":"Signed-off-by: Michel Marti <mma@objectxp.com>\n---\nIMO, the next step should be to tweak git-status/git-commit: I suggest \nintroducing a new option '--what-if' to 'git-commit' that behaves like current\n'git-status [<path>...]' and in return stop 'git-status' from displaying \n'[<path>...]'  as \"Changes to commit\".\n\n Documentation/git-runstatus.txt |    6 +++++-\n builtin-runstatus.c             |    5 ++++-\n wt-status.c                     |   13 ++++++++++++-\n wt-status.h                     |    1 +\n 4 files changed, 22 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-runstatus.txt b/Documentation/git-runstatus.txt\nindex dee5d0d..ddf83ae 100644\n--- a/Documentation/git-runstatus.txt\n+++ b/Documentation/git-runstatus.txt\n@@ -8,7 +8,7 @@ git-runstatus - A helper for git-status and git-commit\n \n SYNOPSIS\n --------\n-'git-runstatus' [--color|--nocolor] [--amend] [--verbose] [--untracked]\n+'git-runstatus' [--color|--nocolor] [--amend] [--verbose] [--untracked] [<path>...]\n \n \n DESCRIPTION\n@@ -47,6 +47,10 @@ OPTIONS\n \toption only its name and a trailing slash are displayed\n \tfor each untracked directory.\n \n+<path>...::\n+\tThe <path> parameters, when given, are used to limit\n+\tthe status to the named path(s).\n+\n \n OUTPUT\n ------\ndiff --git a/builtin-runstatus.c b/builtin-runstatus.c\nindex 2db25c8..6acc92f 100644\n--- a/builtin-runstatus.c\n+++ b/builtin-runstatus.c\n@@ -5,7 +5,7 @@\n extern int wt_status_use_color;\n \n static const char runstatus_usage[] =\n-\"git-runstatus [--color|--nocolor] [--amend] [--verbose] [--untracked]\";\n+\"git-runstatus [--color|--nocolor] [--amend] [--verbose] [--untracked] [<path>...]\";\n \n int cmd_runstatus(int argc, const char **argv, const char *prefix)\n {\n@@ -16,6 +16,8 @@ int cmd_runstatus(int argc, const char **argv, const char *prefix)\n \twt_status_prepare(&s);\n \n \tfor (i = 1; i < argc; i++) {\n+\t\tif (argv[i][0] != '-')\n+\t\t\tbreak;\n \t\tif (!strcmp(argv[i], \"--color\"))\n \t\t\twt_status_use_color = 1;\n \t\telse if (!strcmp(argv[i], \"--nocolor\"))\n@@ -32,6 +34,7 @@ int cmd_runstatus(int argc, const char **argv, const char *prefix)\n \t\t\tusage(runstatus_usage);\n \t}\n \n+\ts.pathspec = argc > i ? get_pathspec(prefix, argv+i) : NULL;\n \twt_status_print(&s);\n \treturn s.commitable ? 0 : 1;\n }\ndiff --git a/wt-status.c b/wt-status.c\nindex 10ce6ee..e40e0d2 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -228,6 +228,7 @@ static void wt_status_print_updated(struct wt_status *s)\n \trev.diffopt.format_callback_data = s;\n \trev.diffopt.detect_rename = 1;\n \trev.diffopt.rename_limit = 100;\n+\trev.prune_data = s->pathspec;\n \twt_read_cache(s);\n \trun_diff_index(&rev, 1);\n }\n@@ -240,6 +241,7 @@ static void wt_status_print_changed(struct wt_status *s)\n \trev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;\n \trev.diffopt.format_callback = wt_status_print_changed_cb;\n \trev.diffopt.format_callback_data = s;\n+\trev.prune_data = s->pathspec;\n \twt_read_cache(s);\n \trun_diff_files(&rev, 0);\n }\n@@ -248,7 +250,8 @@ static void wt_status_print_untracked(struct wt_status *s)\n {\n \tstruct dir_struct dir;\n \tconst char *x;\n-\tint i;\n+\tint i, specs;\n+\tchar *seen;\n \tint shown_header = 0;\n \n \tmemset(&dir, 0, sizeof(dir));\n@@ -264,11 +267,19 @@ static void wt_status_print_untracked(struct wt_status *s)\n \tif (excludes_file && file_exists(excludes_file))\n \t\tadd_excludes_from_file(&dir, excludes_file);\n \n+\tfor (specs = 0; s->pathspec && s->pathspec[specs];  specs++)\n+\t\t/* nothing */;\n+\tif (specs)\n+\t\tseen = xcalloc(specs, 1);\n+\n \tread_directory(&dir, \".\", \"\", 0, NULL);\n \tfor(i = 0; i < dir.nr; i++) {\n \t\t/* check for matching entry, which is unmerged; lifted from\n \t\t * builtin-ls-files:show_other_files */\n \t\tstruct dir_entry *ent = dir.entries[i];\n+\t\tif (specs &&\n+\t\t    !match_pathspec(s->pathspec, ent->name, ent->len, 0, seen))\n+\t\t\t\tcontinue;\n \t\tint pos = cache_name_pos(ent->name, ent->len);\n \t\tstruct cache_entry *ce;\n \t\tif (0 <= pos)\ndiff --git a/wt-status.h b/wt-status.h\nindex cfea4ae..1153e87 100644\n--- a/wt-status.h\n+++ b/wt-status.h\n@@ -15,6 +15,7 @@ struct wt_status {\n \tint verbose;\n \tint amend;\n \tint untracked;\n+\tconst char **pathspec;\n \t/* These are computed during processing of the individual sections */\n \tint commitable;\n \tint workdir_dirty;\n-- \n1.5.3.4.316.g8a37e\n"},{"id":"57371","messageId":"Pine.LNX.4.64.0710271922340.4362@racer.site","threadId":"10492","inReplyTo":"1193508519-14140-1-git-send-email-mma@objectxp.com","subject":"Re: [PATCH] Allow git-runstatus to limit its scope to a set of files/directories.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-27T18:24:09Z","receivedAt":"2007-10-27T18:24:09Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 27 Oct 2007, Michel Marti wrote:\n\n> Signed-off-by: Michel Marti <mma@objectxp.com>\n> ---\n> IMO, the next step should be to tweak git-status/git-commit: I suggest \n> introducing a new option '--what-if' to 'git-commit' that behaves like current\n> 'git-status [<path>...]' and in return stop 'git-status' from displaying \n> '[<path>...]'  as \"Changes to commit\".\n\nI am not sure this is the correct way to go, since \"git status\" as a \"git \ncommit --dry-run\" has worked well so far.\n\nBesides, I would like to see builtin-commit go in as soon as possible, and \nthis patch would delay that.\n\nCiao,\nDscho\n"},{"id":"57372","messageId":"47238729.10901@objectxp.com","threadId":"10492","inReplyTo":"Pine.LNX.4.64.0710271922340.4362@racer.site","subject":"Re: [PATCH] Allow git-runstatus to limit its scope to a set of files/directories.","fromName":"Michel Marti","fromEmail":"mma@objectxp.com","sentAt":"2007-10-27T18:44:57Z","receivedAt":"2007-10-27T18:44:57Z","isPatch":true,"sender":{"key":"mma@objectxp.com","avatar":null},"body":"Johannes Schindelin wrote:\n> On Sat, 27 Oct 2007, Michel Marti wrote:\n> \n>> Signed-off-by: Michel Marti <mma@objectxp.com>\n>> ---\n>> IMO, the next step should be to tweak git-status/git-commit: I suggest \n>> introducing a new option '--what-if' to 'git-commit' that behaves like current\n>> 'git-status [<path>...]' and in return stop 'git-status' from displaying \n>> '[<path>...]'  as \"Changes to commit\".\n> \n> I am not sure this is the correct way to go, since \"git status\" as a \"git \n> commit --dry-run\" has worked well so far.\nMaybe, but current git-status behaviour is somewhat illogical and I'm \npretty sure there are more than a few git-users that were puzzled after \ncalling \"git-status some-dir\" for the first time.\n\n> Besides, I would like to see builtin-commit go in as soon as possible, and \n> this patch would delay that.\nHmmm, why is that? The patch only touches git-runstatus, invoking \n\"git-status <path>\" will behave as usual.\n\n- Michel\n"}]}