diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-10-26 19:48:19 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-10-26 19:48:19 -0700 |
| commit | 3d638cb3892dcfccc22b3e7712b314fd83e2822d (patch) | |
| tree | 35bdbb83134d8bd7e42f03bb3fc7b4324dacd30c | |
| parent | 2319fbae483f4c07bcdd9a850377a0cd21363cff (diff) | |
| parent | 50927f4f683a35ad1c76c8a02a1759a076d3f8f8 (diff) | |
| download | git-3d638cb3892dcfccc22b3e7712b314fd83e2822d.tar.gz | |
Merge branch 'jk/status-z-short-fix' into maint-2.51
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
| -rwxr-xr-x | t/t7508-status.sh | 11 | ||||
| -rw-r--r-- | wt-status.c | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/t/t7508-status.sh b/t/t7508-status.sh index cdc1d6fcc7..abad229e9d 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -717,6 +717,17 @@ test_expect_success TTY 'status -s with color.status' ' ' +test_expect_success TTY 'status -s keeps colors with -z' ' + test_when_finished "rm -f output.*" && + test_terminal git status -s -z >output.raw && + # convert back to newlines to avoid portability issues with + # test_decode_color and test_cmp, and to let us use the same expected + # output as earlier tests + tr "\0" "\n" <output.raw >output.nl && + test_decode_color <output.nl >output && + test_cmp expect output +' + cat >expect <<\EOF ## <YELLOW>main<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>] <RED>M<RESET> dir1/modified diff --git a/wt-status.c b/wt-status.c index 454601afa1..d6917f0a83 100644 --- a/wt-status.c +++ b/wt-status.c @@ -2051,13 +2051,13 @@ static void wt_shortstatus_status(struct string_list_item *it, static void wt_shortstatus_other(struct string_list_item *it, struct wt_status *s, const char *sign) { + color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign); if (s->null_termination) { - fprintf(s->fp, "%s %s%c", sign, it->string, 0); + fprintf(s->fp, " %s%c", it->string, 0); } else { struct strbuf onebuf = STRBUF_INIT; const char *one; one = quote_path(it->string, s->prefix, &onebuf, QUOTE_PATH_QUOTE_SP); - color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign); fprintf(s->fp, " %s\n", one); strbuf_release(&onebuf); } |
