t1003-read-tree-prefix.sh: use the $( ... ) construct for command substitution
[gitweb.git] / wt-status.c
index b1b018e54e9823a4bb73f40a612e340ed5fd47e5..e1827faf073ce384bea6a697dd903ffc643bdfdc 100644 (file)
@@ -17,7 +17,7 @@
 #include "strbuf.h"
 #include "utf8.h"
 
-static char cut_line[] =
+static const char cut_line[] =
 "------------------------ >8 ------------------------\n";
 
 static char default_wt_status_colors[][COLOR_MAXLEN] = {
@@ -318,8 +318,6 @@ static void wt_status_print_unmerged_data(struct wt_status *s,
        if (!padding) {
                label_width = maxwidth(wt_status_unmerged_status_string, 1, 7);
                label_width += strlen(" ");
-               if (label_width < 20)
-                       label_width = 20;
                padding = xmallocz(label_width);
                memset(padding, ' ', label_width);
        }
@@ -545,7 +543,7 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
                struct wt_status_change_data *d;
                const struct cache_entry *ce = active_cache[i];
 
-               if (!ce_path_match(ce, &s->pathspec))
+               if (!ce_path_match(ce, &s->pathspec, NULL))
                        continue;
                it = string_list_insert(&s->change, ce->name);
                d = it->util;
@@ -587,7 +585,7 @@ static void wt_status_collect_untracked(struct wt_status *s)
        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_depth(&s->pathspec, ent->name, ent->len, 0, NULL))
+                   dir_path_match(ent, &s->pathspec, 0, NULL))
                        string_list_insert(&s->untracked, ent->name);
                free(ent);
        }
@@ -595,7 +593,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_depth(&s->pathspec, ent->name, ent->len, 0, NULL))
+                   dir_path_match(ent, &s->pathspec, 0, NULL))
                        string_list_insert(&s->ignored, ent->name);
                free(ent);
        }
@@ -843,6 +841,17 @@ void wt_status_truncate_message_at_cut_line(struct strbuf *buf)
        strbuf_release(&pattern);
 }
 
+void wt_status_add_cut_line(FILE *fp)
+{
+       const char *explanation = _("Do not touch the line above.\nEverything below will be removed.");
+       struct strbuf buf = STRBUF_INIT;
+
+       fprintf(fp, "%c %s", comment_line_char, cut_line);
+       strbuf_add_commented_lines(&buf, explanation, strlen(explanation));
+       fputs(buf.buf, fp);
+       strbuf_release(&buf);
+}
+
 static void wt_status_print_verbose(struct wt_status *s)
 {
        struct rev_info rev;
@@ -868,14 +877,8 @@ static void wt_status_print_verbose(struct wt_status *s)
         * diff before committing.
         */
        if (s->fp != stdout) {
-               const char *explanation = _("Do not touch the line above.\nEverything below will be removed.");
-               struct strbuf buf = STRBUF_INIT;
-
                rev.diffopt.use_color = 0;
-               fprintf(s->fp, "%c %s", comment_line_char, cut_line);
-               strbuf_add_commented_lines(&buf, explanation, strlen(explanation));
-               fputs(buf.buf, s->fp);
-               strbuf_release(&buf);
+               wt_status_add_cut_line(s->fp);
        }
        run_diff_index(&rev, 1);
 }