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>
Nguyễn Thái Ngọc Duy committed
Jul 14, 2013 at 15:35 UTC
15b55ae06a208dea4d10125d9655a84f5b62d781
3 files changed
+13
-14
builtin/commit.c
+5
-4
@@ -1241,11 +1241,12 @@ int cmd_status(int argc, const char **argv, const char *prefix)
1241
handle_untracked_files_arg(&s);
1242
if (show_ignored_in_status)
1243
s.show_ignored_files = 1;
1244
- if (*argv)
1245
- s.pathspec = get_pathspec(prefix, argv);
1244
+ parse_pathspec(&s.pathspec, 0,
1245
+ PATHSPEC_PREFER_FULL,
1246
+ prefix, argv);
1247
1247
- read_cache_preload(s.pathspec);
1248
- refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec, NULL, NULL);
1248
+ read_cache_preload(s.pathspec.raw);
1249
+ refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec.raw, NULL, NULL);
1250
1251
fd = hold_locked_index(&index_lock, 0);
1252
if (0 <= fd)
wt-status.c
+7
-9
@@ -1,4 +1,5 @@
1
#include "cache.h"
2
+#include "pathspec.h"
3
#include "wt-status.h"
4
#include "object.h"
5
#include "dir.h"
@@ -438,7 +439,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
439
}
440
rev.diffopt.format_callback = wt_status_collect_changed_cb;
441
rev.diffopt.format_callback_data = s;
441
- init_pathspec(&rev.prune_data, s->pathspec);
442
+ copy_pathspec(&rev.prune_data, &s->pathspec);
443
run_diff_files(&rev, 0);
444
}
445
@@ -463,22 +464,20 @@ static void wt_status_collect_changes_index(struct wt_status *s)
464
rev.diffopt.detect_rename = 1;
465
rev.diffopt.rename_limit = 200;
466
rev.diffopt.break_opt = 0;
466
- init_pathspec(&rev.prune_data, s->pathspec);
467
+ copy_pathspec(&rev.prune_data, &s->pathspec);
468
run_diff_index(&rev, 1);
469
}
470
471
static void wt_status_collect_changes_initial(struct wt_status *s)
472
{
472
- struct pathspec pathspec;
473
int i;
474
475
- init_pathspec(&pathspec, s->pathspec);
475
for (i = 0; i < active_nr; i++) {
476
struct string_list_item *it;
477
struct wt_status_change_data *d;
478
struct cache_entry *ce = active_cache[i];
479
481
- if (!ce_path_match(ce, &pathspec))
480
+ if (!ce_path_match(ce, &s->pathspec))
481
continue;
482
it = string_list_insert(&s->change, ce->name);
483
d = it->util;
@@ -493,7 +492,6 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
492
else
493
d->index_status = DIFF_STATUS_ADDED;
494
}
496
- free_pathspec(&pathspec);
495
}
496
497
static void wt_status_collect_untracked(struct wt_status *s)
@@ -516,12 +514,12 @@ static void wt_status_collect_untracked(struct wt_status *s)
514
dir.flags |= DIR_SHOW_IGNORED_TOO;
515
setup_standard_excludes(&dir);
516
519
- fill_directory(&dir, s->pathspec);
517
+ fill_directory(&dir, s->pathspec.raw);
518
519
for (i = 0; i < dir.nr; i++) {
520
struct dir_entry *ent = dir.entries[i];
521
if (cache_name_is_other(ent->name, ent->len) &&
524
- match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
522
+ match_pathspec_depth(&s->pathspec, ent->name, ent->len, 0, NULL))
523
string_list_insert(&s->untracked, ent->name);
524
free(ent);
525
}
@@ -529,7 +527,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
527
for (i = 0; i < dir.ignored_nr; i++) {
528
struct dir_entry *ent = dir.ignored[i];
529
if (cache_name_is_other(ent->name, ent->len) &&
532
- match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
530
+ match_pathspec_depth(&s->pathspec, ent->name, ent->len, 0, NULL))
531
string_list_insert(&s->ignored, ent->name);
532
free(ent);
533
}
wt-status.h
+1
-1
@@ -44,7 +44,7 @@ struct wt_status {
44
int is_initial;
45
char *branch;
46
const char *reference;
47
- const char **pathspec;
47
+ struct pathspec pathspec;
48
int verbose;
49
int amend;
50
enum commit_whence whence;