Merge branch 'mm/fast-import-feature-doc'
[gitweb.git] / wt-status.c
index 9c4d086b51364ff42a044be95e6ea55dffe7b79e..ff4b32426a36db38fba9e4cc51e09a988efe34a6 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "pathspec.h"
 #include "wt-status.h"
 #include "object.h"
 #include "dir.h"
@@ -244,7 +245,7 @@ static void wt_status_print_unmerged_data(struct wt_status *s,
        struct strbuf onebuf = STRBUF_INIT;
        const char *one, *how = _("bug");
 
-       one = quote_path(it->string, -1, &onebuf, s->prefix);
+       one = quote_path(it->string, s->prefix, &onebuf);
        status_printf(s, color(WT_STATUS_HEADER, s), "\t");
        switch (d->stagemask) {
        case 1: how = _("both deleted:"); break;
@@ -298,8 +299,8 @@ static void wt_status_print_change_data(struct wt_status *s,
                    change_type);
        }
 
-       one = quote_path(one_name, -1, &onebuf, s->prefix);
-       two = quote_path(two_name, -1, &twobuf, s->prefix);
+       one = quote_path(one_name, s->prefix, &onebuf);
+       two = quote_path(two_name, s->prefix, &twobuf);
 
        status_printf(s, color(WT_STATUS_HEADER, s), "\t");
        switch (status) {
@@ -372,7 +373,7 @@ static void wt_status_collect_changed_cb(struct diff_queue_struct *q,
 static int unmerged_mask(const char *path)
 {
        int pos, mask;
-       struct cache_entry *ce;
+       const struct cache_entry *ce;
 
        pos = cache_name_pos(path, strlen(path));
        if (0 <= pos)
@@ -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_data = s;
-       init_pathspec(&rev.prune_data, s->pathspec);
+       copy_pathspec(&rev.prune_data, &s->pathspec);
        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.rename_limit = 200;
        rev.diffopt.break_opt = 0;
-       init_pathspec(&rev.prune_data, s->pathspec);
+       copy_pathspec(&rev.prune_data, &s->pathspec);
        run_diff_index(&rev, 1);
 }
 
 static void wt_status_collect_changes_initial(struct wt_status *s)
 {
-       struct pathspec pathspec;
        int i;
 
-       init_pathspec(&pathspec, s->pathspec);
        for (i = 0; i < active_nr; i++) {
                struct string_list_item *it;
                struct wt_status_change_data *d;
-               struct cache_entry *ce = active_cache[i];
+               const struct cache_entry *ce = active_cache[i];
 
-               if (!ce_path_match(ce, &pathspec))
+               if (!ce_path_match(ce, &s->pathspec))
                        continue;
                it = string_list_insert(&s->change, ce->name);
                d = it->util;
@@ -493,7 +492,6 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
                else
                        d->index_status = DIFF_STATUS_ADDED;
        }
-       free_pathspec(&pathspec);
 }
 
 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;
        setup_standard_excludes(&dir);
 
-       fill_directory(&dir, s->pathspec);
+       fill_directory(&dir, &s->pathspec);
 
        for (i = 0; i < dir.nr; i++) {
                struct dir_entry *ent = dir.entries[i];
                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);
                free(ent);
        }
@@ -529,7 +527,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
        for (i = 0; i < dir.ignored_nr; i++) {
                struct dir_entry *ent = dir.ignored[i];
                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);
                free(ent);
        }
@@ -707,8 +705,7 @@ static void wt_status_print_other(struct wt_status *s,
                struct string_list_item *it;
                const char *path;
                it = &(l->items[i]);
-               path = quote_path(it->string, strlen(it->string),
-                                 &buf, s->prefix);
+               path = quote_path(it->string, s->prefix, &buf);
                if (column_active(s->colopts)) {
                        string_list_append(&output, path);
                        continue;
@@ -1293,7 +1290,7 @@ static void wt_shortstatus_unmerged(struct string_list_item *it,
        } else {
                struct strbuf onebuf = STRBUF_INIT;
                const char *one;
-               one = quote_path(it->string, -1, &onebuf, s->prefix);
+               one = quote_path(it->string, s->prefix, &onebuf);
                printf(" %s\n", one);
                strbuf_release(&onebuf);
        }
@@ -1321,7 +1318,7 @@ static void wt_shortstatus_status(struct string_list_item *it,
                struct strbuf onebuf = STRBUF_INIT;
                const char *one;
                if (d->head_path) {
-                       one = quote_path(d->head_path, -1, &onebuf, s->prefix);
+                       one = quote_path(d->head_path, s->prefix, &onebuf);
                        if (*one != '"' && strchr(one, ' ') != NULL) {
                                putchar('"');
                                strbuf_addch(&onebuf, '"');
@@ -1330,7 +1327,7 @@ static void wt_shortstatus_status(struct string_list_item *it,
                        printf("%s -> ", one);
                        strbuf_release(&onebuf);
                }
-               one = quote_path(it->string, -1, &onebuf, s->prefix);
+               one = quote_path(it->string, s->prefix, &onebuf);
                if (*one != '"' && strchr(one, ' ') != NULL) {
                        putchar('"');
                        strbuf_addch(&onebuf, '"');
@@ -1349,7 +1346,7 @@ static void wt_shortstatus_other(struct string_list_item *it,
        } else {
                struct strbuf onebuf = STRBUF_INIT;
                const char *one;
-               one = quote_path(it->string, -1, &onebuf, s->prefix);
+               one = quote_path(it->string, s->prefix, &onebuf);
                color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign);
                printf(" %s\n", one);
                strbuf_release(&onebuf);