status: convert to use parse_pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
6654c8894e
commit
15b55ae06a
@ -1241,11 +1241,12 @@ int cmd_status(int argc, const char **argv, const char *prefix)
|
|||||||
handle_untracked_files_arg(&s);
|
handle_untracked_files_arg(&s);
|
||||||
if (show_ignored_in_status)
|
if (show_ignored_in_status)
|
||||||
s.show_ignored_files = 1;
|
s.show_ignored_files = 1;
|
||||||
if (*argv)
|
parse_pathspec(&s.pathspec, 0,
|
||||||
s.pathspec = get_pathspec(prefix, argv);
|
PATHSPEC_PREFER_FULL,
|
||||||
|
prefix, argv);
|
||||||
|
|
||||||
read_cache_preload(s.pathspec);
|
read_cache_preload(s.pathspec.raw);
|
||||||
refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec, NULL, NULL);
|
refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec.raw, NULL, NULL);
|
||||||
|
|
||||||
fd = hold_locked_index(&index_lock, 0);
|
fd = hold_locked_index(&index_lock, 0);
|
||||||
if (0 <= fd)
|
if (0 <= fd)
|
||||||
|
16
wt-status.c
16
wt-status.c
@ -1,4 +1,5 @@
|
|||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
|
#include "pathspec.h"
|
||||||
#include "wt-status.h"
|
#include "wt-status.h"
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
#include "dir.h"
|
#include "dir.h"
|
||||||
@ -438,7 +439,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
|
|||||||
}
|
}
|
||||||
rev.diffopt.format_callback = wt_status_collect_changed_cb;
|
rev.diffopt.format_callback = wt_status_collect_changed_cb;
|
||||||
rev.diffopt.format_callback_data = s;
|
rev.diffopt.format_callback_data = s;
|
||||||
init_pathspec(&rev.prune_data, s->pathspec);
|
copy_pathspec(&rev.prune_data, &s->pathspec);
|
||||||
run_diff_files(&rev, 0);
|
run_diff_files(&rev, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,22 +464,20 @@ static void wt_status_collect_changes_index(struct wt_status *s)
|
|||||||
rev.diffopt.detect_rename = 1;
|
rev.diffopt.detect_rename = 1;
|
||||||
rev.diffopt.rename_limit = 200;
|
rev.diffopt.rename_limit = 200;
|
||||||
rev.diffopt.break_opt = 0;
|
rev.diffopt.break_opt = 0;
|
||||||
init_pathspec(&rev.prune_data, s->pathspec);
|
copy_pathspec(&rev.prune_data, &s->pathspec);
|
||||||
run_diff_index(&rev, 1);
|
run_diff_index(&rev, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wt_status_collect_changes_initial(struct wt_status *s)
|
static void wt_status_collect_changes_initial(struct wt_status *s)
|
||||||
{
|
{
|
||||||
struct pathspec pathspec;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
init_pathspec(&pathspec, s->pathspec);
|
|
||||||
for (i = 0; i < active_nr; i++) {
|
for (i = 0; i < active_nr; i++) {
|
||||||
struct string_list_item *it;
|
struct string_list_item *it;
|
||||||
struct wt_status_change_data *d;
|
struct wt_status_change_data *d;
|
||||||
struct cache_entry *ce = active_cache[i];
|
struct cache_entry *ce = active_cache[i];
|
||||||
|
|
||||||
if (!ce_path_match(ce, &pathspec))
|
if (!ce_path_match(ce, &s->pathspec))
|
||||||
continue;
|
continue;
|
||||||
it = string_list_insert(&s->change, ce->name);
|
it = string_list_insert(&s->change, ce->name);
|
||||||
d = it->util;
|
d = it->util;
|
||||||
@ -493,7 +492,6 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
|
|||||||
else
|
else
|
||||||
d->index_status = DIFF_STATUS_ADDED;
|
d->index_status = DIFF_STATUS_ADDED;
|
||||||
}
|
}
|
||||||
free_pathspec(&pathspec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wt_status_collect_untracked(struct wt_status *s)
|
static void wt_status_collect_untracked(struct wt_status *s)
|
||||||
@ -516,12 +514,12 @@ static void wt_status_collect_untracked(struct wt_status *s)
|
|||||||
dir.flags |= DIR_SHOW_IGNORED_TOO;
|
dir.flags |= DIR_SHOW_IGNORED_TOO;
|
||||||
setup_standard_excludes(&dir);
|
setup_standard_excludes(&dir);
|
||||||
|
|
||||||
fill_directory(&dir, s->pathspec);
|
fill_directory(&dir, s->pathspec.raw);
|
||||||
|
|
||||||
for (i = 0; i < dir.nr; i++) {
|
for (i = 0; i < dir.nr; i++) {
|
||||||
struct dir_entry *ent = dir.entries[i];
|
struct dir_entry *ent = dir.entries[i];
|
||||||
if (cache_name_is_other(ent->name, ent->len) &&
|
if (cache_name_is_other(ent->name, ent->len) &&
|
||||||
match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
|
match_pathspec_depth(&s->pathspec, ent->name, ent->len, 0, NULL))
|
||||||
string_list_insert(&s->untracked, ent->name);
|
string_list_insert(&s->untracked, ent->name);
|
||||||
free(ent);
|
free(ent);
|
||||||
}
|
}
|
||||||
@ -529,7 +527,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
|
|||||||
for (i = 0; i < dir.ignored_nr; i++) {
|
for (i = 0; i < dir.ignored_nr; i++) {
|
||||||
struct dir_entry *ent = dir.ignored[i];
|
struct dir_entry *ent = dir.ignored[i];
|
||||||
if (cache_name_is_other(ent->name, ent->len) &&
|
if (cache_name_is_other(ent->name, ent->len) &&
|
||||||
match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
|
match_pathspec_depth(&s->pathspec, ent->name, ent->len, 0, NULL))
|
||||||
string_list_insert(&s->ignored, ent->name);
|
string_list_insert(&s->ignored, ent->name);
|
||||||
free(ent);
|
free(ent);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ struct wt_status {
|
|||||||
int is_initial;
|
int is_initial;
|
||||||
char *branch;
|
char *branch;
|
||||||
const char *reference;
|
const char *reference;
|
||||||
const char **pathspec;
|
struct pathspec pathspec;
|
||||||
int verbose;
|
int verbose;
|
||||||
int amend;
|
int amend;
|
||||||
enum commit_whence whence;
|
enum commit_whence whence;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user