bundle transport: fix an alloc_ref() call
[gitweb.git] / wt-status.c
index 2879c3d5ecc5483dea779116381a036fd2dd0b45..10ce6eedc7e8adbcc3b12e1987d2e16b532a4e07 100644 (file)
@@ -22,6 +22,7 @@ static const char use_add_rm_msg[] =
 "use \"git add/rm <file>...\" to update what will be committed";
 static const char use_add_to_include_msg[] =
 "use \"git add <file>...\" to include in what will be committed";
+static const char *excludes_file;
 
 static int parse_status_slot(const char *var, int offset)
 {
@@ -191,12 +192,18 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
                wt_status_print_trailer();
 }
 
-void wt_status_print_initial(struct wt_status *s)
+static void wt_read_cache(struct wt_status *s)
+{
+       discard_cache();
+       read_cache();
+}
+
+static 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 +227,8 @@ 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;
+       rev.diffopt.rename_limit = 100;
+       wt_read_cache(s);
        run_diff_index(&rev, 1);
 }
 
@@ -231,6 +240,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);
 }
 
@@ -251,8 +261,10 @@ static void wt_status_print_untracked(struct wt_status *s)
        x = git_path("info/exclude");
        if (file_exists(x))
                add_excludes_from_file(&dir, x);
+       if (excludes_file && file_exists(excludes_file))
+               add_excludes_from_file(&dir, excludes_file);
 
-       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 +299,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 +311,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 +329,6 @@ void wt_status_print(struct wt_status *s)
        }
        else {
                wt_status_print_updated(s);
-               discard_cache();
        }
 
        wt_status_print_changed(s);
@@ -344,9 +356,15 @@ 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]);
        }
+       if (!strcmp(k, "core.excludesfile")) {
+               if (!v)
+                       die("core.excludesfile without value");
+               excludes_file = xstrdup(v);
+               return 0;
+       }
        return git_default_config(k, v);
 }