On Wed, Aug 05, 2009 at 02:15:46AM -0700, Junio C Hamano wrote: > --- > Makefile | 1 + > builtin-commit.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > builtin.h | 1 + > git.c | 1 + Missing docs, of course, and tests would be nice. Is this meant to be plumbing? If not, the name is too long to type. ;) > +int cmd_shortstatus(int argc, const char **argv, const char *prefix) > +{ > + struct wt_status s; > + static int null_termination; > + int i; > + static struct option builtin_shortstatus_options[] = { > + OPT_BOOLEAN('z', "null", &null_termination, > + "terminate entries with NUL"), > + OPT_END(), > + }; > + > + argc = parse_options(argc, argv, prefix, > + builtin_shortstatus_options, > + builtin_shortstatus_usage, 0); I think one of the most often-requested things for a "git status" replacement is that "git status <path>" do path-limiting. Something like (the extremely not very well tested): --- diff --git a/builtin-commit.c b/builtin-commit.c index 7a4ddab..8bc6269 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -891,7 +891,12 @@ int cmd_shortstatus(int argc, const char **argv, const char *prefix) read_cache(); refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED); + wt_status_prepare(&s); + ALLOC_GROW(s.path_limit, s.path_limit_nr + argc, s.path_limit_alloc); + for (i = 0; i < argc; i++) + s.path_limit[s.path_limit_nr++] = argv[i]; + wt_status_collect_changes(&s); for (i = 0; i < s.change.nr; i++) { struct wt_status_change_data *d; diff --git a/wt-status.c b/wt-status.c index 5a68297..7399e1b 100644 --- a/wt-status.c +++ b/wt-status.c @@ -60,6 +60,12 @@ void wt_status_prepare(struct wt_status *s) s->fp = stdout; s->index_file = get_index_file(); s->change.strdup_strings = 1; + + s->path_limit = xmalloc(2 * sizeof(*s->path_limit)); + s->path_limit_nr = 1; + s->path_limit_alloc = 2; + s->path_limit[0] = "dummy argv[0]"; + s->path_limit[1] = NULL; } static void wt_status_print_unmerged_header(struct wt_status *s) @@ -283,7 +289,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) struct rev_info rev; init_revisions(&rev, NULL); - setup_revisions(0, NULL, &rev, NULL); + setup_revisions(s->path_limit_nr, s->path_limit, &rev, NULL); rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback_data = s; @@ -295,7 +301,7 @@ static void wt_status_collect_changes_index(struct wt_status *s) struct rev_info rev; init_revisions(&rev, NULL); - setup_revisions(0, NULL, &rev, + setup_revisions(s->path_limit_nr, s->path_limit, &rev, s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference); rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = wt_status_collect_updated_cb; @@ -315,6 +321,10 @@ static void wt_status_collect_changes_initial(struct wt_status *s) struct wt_status_change_data *d; struct cache_entry *ce = active_cache[i]; + if (match_pathspec(s->path_limit + 1, + ce->name, strlen(ce->name), 0, NULL)) + continue; + it = string_list_insert(ce->name, &s->change); d = it->util; if (!d) { @@ -477,7 +487,7 @@ static void wt_status_print_untracked(struct wt_status *s) DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES; setup_standard_excludes(&dir); - fill_directory(&dir, NULL); + fill_directory(&dir, s->path_limit + 1); for(i = 0; i < dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; if (!cache_name_is_other(ent->name, ent->len)) @@ -559,6 +569,9 @@ void wt_status_print(struct wt_status *s) wt_status_print_tracking(s); } + ALLOC_GROW(s->path_limit, s->path_limit_nr + 1, s->path_limit_alloc); + s->path_limit[s->path_limit_nr] = NULL; + wt_status_collect_changes(s); if (s->is_initial) { diff --git a/wt-status.h b/wt-status.h index f80142f..3099e99 100644 --- a/wt-status.h +++ b/wt-status.h @@ -43,6 +43,8 @@ struct wt_status { FILE *fp; const char *prefix; struct string_list change; + const char **path_limit; + int path_limit_nr, path_limit_alloc; }; int git_status_config(const char *var, const char *value, void *cb); -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html