Code

status -s: obey color.status
authorMichael J Gruber <git@drmicha.warpmail.net>
Sat, 5 Dec 2009 15:04:38 +0000 (16:04 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 5 Dec 2009 17:27:56 +0000 (09:27 -0800)
Make the short version of status obey the color.status boolean. We color
the status letters only, because they carry the state information and are
potentially colored differently, such as for a file with staged changes
as well as changes in the worktree against the index.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-commit.c
wt-status.c

index 8411236fda1f74a6b5aa861ce81775c49290e4d2..07cc76c04a4b7040a4fc9fe94744f13a1848c5ff 100644 (file)
@@ -968,6 +968,10 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        case STATUS_FORMAT_SHORT:
                if (s.relative_paths)
                        s.prefix = prefix;
+               if (s.use_color == -1)
+                       s.use_color = git_use_color_default;
+               if (diff_use_color_default == -1)
+                       diff_use_color_default = git_use_color_default;
                wt_shortstatus_print(&s, null_termination);
                break;
        case STATUS_FORMAT_PORCELAIN:
index 8ef824e0d942b7d85789ceb15608dbbde0a6d557..696c6b0bf1eac0282fbd6e140f5ddda66d7f5a93 100644 (file)
@@ -608,14 +608,14 @@ static void wt_shortstatus_unmerged(int null_termination, struct string_list_ite
        case 6: how = "AA"; break; /* both added */
        case 7: how = "UU"; break; /* both modified */
        }
-       printf("%s ", how);
+       color_fprintf(s->fp, color(WT_STATUS_UNMERGED, s), "%s", how);
        if (null_termination) {
-               fprintf(stdout, "%s%c", it->string, 0);
+               fprintf(stdout, " %s%c", it->string, 0);
        } else {
                struct strbuf onebuf = STRBUF_INIT;
                const char *one;
                one = quote_path(it->string, -1, &onebuf, s->prefix);
-               printf("%s\n", one);
+               printf(" %s\n", one);
                strbuf_release(&onebuf);
        }
 }
@@ -625,9 +625,15 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item
 {
        struct wt_status_change_data *d = it->util;
 
-       printf("%c%c ",
-               !d->index_status ? ' ' : d->index_status,
-               !d->worktree_status ? ' ' : d->worktree_status);
+       if (d->index_status)
+               color_fprintf(s->fp, color(WT_STATUS_UPDATED, s), "%c", d->index_status);
+       else
+               putchar(' ');
+       if (d->worktree_status)
+               color_fprintf(s->fp, color(WT_STATUS_CHANGED, s), "%c", d->worktree_status);
+       else
+               putchar(' ');
+       putchar(' ');
        if (null_termination) {
                fprintf(stdout, "%s%c", it->string, 0);
                if (d->head_path)
@@ -655,7 +661,8 @@ static void wt_shortstatus_untracked(int null_termination, struct string_list_it
                struct strbuf onebuf = STRBUF_INIT;
                const char *one;
                one = quote_path(it->string, -1, &onebuf, s->prefix);
-               printf("?? %s\n", one);
+               color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "??");
+               printf(" %s\n", one);
                strbuf_release(&onebuf);
        }
 }