Skip to content

Commit e7909b3

Browse files
committed
Merge branch 'jk/status-z-short-fix'
The "--short" option of "git status" that meant output for humans and "-z" option to show NUL delimited output format did not mix well, and colored some but not all things. The command has been updated to color all elements consistently in such a case. * jk/status-z-short-fix: status: make coloring of "-z --short" consistent
2 parents 385772e + 50927f4 commit e7909b3

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

t/t7508-status.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,17 @@ test_expect_success TTY 'status -s with color.status' '
717717
718718
'
719719

720+
test_expect_success TTY 'status -s keeps colors with -z' '
721+
test_when_finished "rm -f output.*" &&
722+
test_terminal git status -s -z >output.raw &&
723+
# convert back to newlines to avoid portability issues with
724+
# test_decode_color and test_cmp, and to let us use the same expected
725+
# output as earlier tests
726+
tr "\0" "\n" <output.raw >output.nl &&
727+
test_decode_color <output.nl >output &&
728+
test_cmp expect output
729+
'
730+
720731
cat >expect <<\EOF
721732
## <YELLOW>main<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>]
722733
<RED>M<RESET> dir1/modified

wt-status.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,13 +2042,13 @@ static void wt_shortstatus_status(struct string_list_item *it,
20422042
static void wt_shortstatus_other(struct string_list_item *it,
20432043
struct wt_status *s, const char *sign)
20442044
{
2045+
color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign);
20452046
if (s->null_termination) {
2046-
fprintf(s->fp, "%s %s%c", sign, it->string, 0);
2047+
fprintf(s->fp, " %s%c", it->string, 0);
20472048
} else {
20482049
struct strbuf onebuf = STRBUF_INIT;
20492050
const char *one;
20502051
one = quote_path(it->string, s->prefix, &onebuf, QUOTE_PATH_QUOTE_SP);
2051-
color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign);
20522052
fprintf(s->fp, " %s\n", one);
20532053
strbuf_release(&onebuf);
20542054
}

0 commit comments

Comments
 (0)