Re: git column fails (or crashes) if padding is negative
From: Kristoffer Haugsbakk <hidden>
Date: 2024-02-11 17:08:31
On Fri, Feb 9, 2024, at 18:57, Junio C Hamano wrote:
quoted hunk ↗ jump to hunk
builtin/column.c | 2 ++ column.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) […]diff --git c/column.c w/column.c index ff2f0abf39..9cc703832a 100644 --- c/column.c +++ w/column.c@@ -189,7 +189,7 @@ void print_columns(const struct string_list *list,unsigned int colopts, memset(&nopts, 0, sizeof(nopts)); nopts.indent = opts && opts->indent ? opts->indent : ""; nopts.nl = opts && opts->nl ? opts->nl : "\n"; - nopts.padding = opts ? opts->padding : 1; + nopts.padding = (opts && 0 < opts->padding) ? opts->padding : 1;
If these two are meant to check the same condition as in `builtin/column.c`, shouldn’t it be `0 <= opts->padding`?
quoted hunk ↗ jump to hunk
nopts.width = opts && opts->width ? opts->width : term_columns() - 1; if (!column_active(colopts)) { display_plain(list, "", "\n");@@ -373,7 +373,7 @@ int run_column_filter(int colopts, const structcolumn_options *opts) strvec_pushf(argv, "--width=%d", opts->width); if (opts && opts->indent) strvec_pushf(argv, "--indent=%s", opts->indent); - if (opts && opts->padding) + if (opts && 0 < opts->padding) strvec_pushf(argv, "--padding=%d", opts->padding); fflush(stdout);
-- Kristoffer Haugsbakk