]> git.ipfire.org Git - thirdparty/git.git/blobdiff - wt-status.c
Add basic infrastructure to assign attributes to paths
[thirdparty/git.git] / wt-status.c
index 2879c3d5ecc5483dea779116381a036fd2dd0b45..a0559905a0b7072f4a4b44ea321c1316cfc84414 100644 (file)
@@ -191,12 +191,18 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
                wt_status_print_trailer();
 }
 
+static void wt_read_cache(struct wt_status *s)
+{
+       discard_cache();
+       read_cache();
+}
+
 void wt_status_print_initial(struct wt_status *s)
 {
        int i;
        char buf[PATH_MAX];
 
-       read_cache();
+       wt_read_cache(s);
        if (active_nr) {
                s->commitable = 1;
                wt_status_print_cached_header(NULL);
@@ -220,6 +226,7 @@ static void wt_status_print_updated(struct wt_status *s)
        rev.diffopt.format_callback = wt_status_print_updated_cb;
        rev.diffopt.format_callback_data = s;
        rev.diffopt.detect_rename = 1;
+       wt_read_cache(s);
        run_diff_index(&rev, 1);
 }
 
@@ -231,6 +238,7 @@ static void wt_status_print_changed(struct wt_status *s)
        rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
        rev.diffopt.format_callback = wt_status_print_changed_cb;
        rev.diffopt.format_callback_data = s;
+       wt_read_cache(s);
        run_diff_files(&rev, 0);
 }
 
@@ -252,7 +260,7 @@ static void wt_status_print_untracked(struct wt_status *s)
        if (file_exists(x))
                add_excludes_from_file(&dir, x);
 
-       read_directory(&dir, ".", "", 0);
+       read_directory(&dir, ".", "", 0, NULL);
        for(i = 0; i < dir.nr; i++) {
                /* check for matching entry, which is unmerged; lifted from
                 * builtin-ls-files:show_other_files */
@@ -287,6 +295,7 @@ static void wt_status_print_verbose(struct wt_status *s)
        setup_revisions(0, NULL, &rev, s->reference);
        rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
        rev.diffopt.detect_rename = 1;
+       wt_read_cache(s);
        run_diff_index(&rev, 1);
 }
 
@@ -298,7 +307,7 @@ void wt_status_print(struct wt_status *s)
        if (s->branch) {
                const char *on_what = "On branch ";
                const char *branch_name = s->branch;
-               if (!strncmp(branch_name, "refs/heads/", 11))
+               if (!prefixcmp(branch_name, "refs/heads/"))
                        branch_name += 11;
                else if (!strcmp(branch_name, "HEAD")) {
                        branch_name = "";
@@ -316,7 +325,6 @@ void wt_status_print(struct wt_status *s)
        }
        else {
                wt_status_print_updated(s);
-               discard_cache();
        }
 
        wt_status_print_changed(s);
@@ -344,7 +352,7 @@ int git_status_config(const char *k, const char *v)
                wt_status_use_color = git_config_colorbool(k, v);
                return 0;
        }
-       if (!strncmp(k, "status.color.", 13) || !strncmp(k, "color.status.", 13)) {
+       if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
                int slot = parse_status_slot(k, 13);
                color_parse(v, k, wt_status_colors[slot]);
        }