status -s: obey color.status
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>
Michael J Gruber committed
Dec 5, 2009 at 16:04 UTC
3fe2a894e98566dd91e69982552454cfb381cf24
2 files changed
+18
-7
builtin-commit.c
+4
@@ -968,6 +968,10 @@ int cmd_status(int argc, const char **argv, const char *prefix)
968
case STATUS_FORMAT_SHORT:
969
if (s.relative_paths)
970
s.prefix = prefix;
971
+ if (s.use_color == -1)
972
+ s.use_color = git_use_color_default;
973
+ if (diff_use_color_default == -1)
974
+ diff_use_color_default = git_use_color_default;
975
wt_shortstatus_print(&s, null_termination);
976
break;
977
case STATUS_FORMAT_PORCELAIN:
wt-status.c
+14
-7
@@ -608,14 +608,14 @@ static void wt_shortstatus_unmerged(int null_termination, struct string_list_ite
608
case 6: how = "AA"; break; /* both added */
609
case 7: how = "UU"; break; /* both modified */
610
}
611
- printf("%s ", how);
611
+ color_fprintf(s->fp, color(WT_STATUS_UNMERGED, s), "%s", how);
612
if (null_termination) {
613
- fprintf(stdout, "%s%c", it->string, 0);
613
+ fprintf(stdout, " %s%c", it->string, 0);
614
} else {
615
struct strbuf onebuf = STRBUF_INIT;
616
const char *one;
617
one = quote_path(it->string, -1, &onebuf, s->prefix);
618
- printf("%s\n", one);
618
+ printf(" %s\n", one);
619
strbuf_release(&onebuf);
620
}
621
}
@@ -625,9 +625,15 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item
625
{
626
struct wt_status_change_data *d = it->util;
627
628
- printf("%c%c ",
629
- !d->index_status ? ' ' : d->index_status,
630
- !d->worktree_status ? ' ' : d->worktree_status);
628
+ if (d->index_status)
629
+ color_fprintf(s->fp, color(WT_STATUS_UPDATED, s), "%c", d->index_status);
630
+ else
631
+ putchar(' ');
632
+ if (d->worktree_status)
633
+ color_fprintf(s->fp, color(WT_STATUS_CHANGED, s), "%c", d->worktree_status);
634
+ else
635
+ putchar(' ');
636
+ putchar(' ');
637
if (null_termination) {
638
fprintf(stdout, "%s%c", it->string, 0);
639
if (d->head_path)
@@ -655,7 +661,8 @@ static void wt_shortstatus_untracked(int null_termination, struct string_list_it
661
struct strbuf onebuf = STRBUF_INIT;
662
const char *one;
663
one = quote_path(it->string, -1, &onebuf, s->prefix);
658
- printf("?? %s\n", one);
664
+ color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "??");
665
+ printf(" %s\n", one);
666
strbuf_release(&onebuf);
667
}
668
}