]> git.ipfire.org Git - thirdparty/git.git/blobdiff - wt-status.c
pack-objects: Fix segfault when object count is less than thread count
[thirdparty/git.git] / wt-status.c
index 0e0439f2c2d8f19abba0a683ce1b2ab3db6197ba..c0c247243b562a7579ff780b80dffef4774b60a9 100644 (file)
@@ -8,6 +8,7 @@
 #include "revision.h"
 #include "diffcore.h"
 
+int wt_status_relative_paths = 1;
 int wt_status_use_color = 0;
 static char wt_status_colors[][COLOR_MAXLEN] = {
        "",         /* WT_STATUS_HEADER: normal */
@@ -82,12 +83,13 @@ static void wt_status_print_trailer(struct wt_status *s)
 }
 
 static char *quote_path(const char *in, int len,
-               struct strbuf *out, const char *prefix)
+                       struct strbuf *out, const char *prefix)
 {
-       if (len > 0)
-               strbuf_grow(out, len);
-       strbuf_setlen(out, 0);
+       if (len < 0)
+               len = strlen(in);
 
+       strbuf_grow(out, len);
+       strbuf_setlen(out, 0);
        if (prefix) {
                int off = 0;
                while (prefix[off] && off < len && prefix[off] == in[off])
@@ -104,7 +106,7 @@ static char *quote_path(const char *in, int len,
                                strbuf_addstr(out, "../");
        }
 
-       for (; (len < 0 && *in) || len > 0; in++, len--) {
+       for ( ; len > 0; in++, len--) {
                int ch = *in;
 
                switch (ch) {
@@ -120,6 +122,9 @@ static char *quote_path(const char *in, int len,
                }
        }
 
+       if (!out->len)
+               strbuf_addstr(out, "./");
+
        return out->buf;
 }
 
@@ -250,6 +255,7 @@ static void wt_status_print_updated(struct wt_status *s)
        rev.diffopt.format_callback_data = s;
        rev.diffopt.detect_rename = 1;
        rev.diffopt.rename_limit = 100;
+       rev.diffopt.break_opt = 0;
        wt_read_cache(s);
        run_diff_index(&rev, 1);
 }
@@ -375,6 +381,8 @@ void wt_status_print(struct wt_status *s)
        if (!s->commitable) {
                if (s->amend)
                        fprintf(s->fp, "# No changes\n");
+               else if (s->nowarn)
+                       ; /* nothing */
                else if (s->workdir_dirty)
                        printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n");
                else if (s->workdir_untracked)
@@ -389,12 +397,17 @@ void wt_status_print(struct wt_status *s)
 int git_status_config(const char *k, const char *v)
 {
        if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
-               wt_status_use_color = git_config_colorbool(k, v);
+               wt_status_use_color = git_config_colorbool(k, v, -1);
                return 0;
        }
        if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
                int slot = parse_status_slot(k, 13);
                color_parse(v, k, wt_status_colors[slot]);
+               return 0;
+       }
+       if (!strcmp(k, "status.relativepaths")) {
+               wt_status_relative_paths = git_config_bool(k, v);
+               return 0;
        }
        return git_default_config(k, v);
 }