Skip to content

Commit ce8529b

Browse files
committed
diff: leave NEEDWORK notes in show_stats() function
The previous step made an attempt to correctly compute display columns allocated and padded different parts of diffstat output. There are at least two known codepaths in the function that still mixes up display widths and byte length that need to be fixed. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 12fc4ad commit ce8529b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

diff.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,6 +2675,11 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
26752675
* making the line longer than the maximum width.
26762676
*/
26772677

2678+
/*
2679+
* NEEDSWORK: line_prefix is often used for "log --graph" output
2680+
* and contains ANSI-colored string. utf8_strnwidth() should be
2681+
* used to correctly count the display width instead of strlen().
2682+
*/
26782683
if (options->stat_width == -1)
26792684
width = term_columns() - strlen(line_prefix);
26802685
else
@@ -2750,6 +2755,16 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
27502755
char *slash;
27512756
prefix = "...";
27522757
len -= 3;
2758+
/*
2759+
* NEEDSWORK: (name_len - len) counts the display
2760+
* width, which would be shorter than the byte
2761+
* length of the corresponding substring.
2762+
* Advancing "name" by that number of bytes does
2763+
* *NOT* skip over that many columns, so it is
2764+
* very likely that chomping the pathname at the
2765+
* slash we will find starting from "name" will
2766+
* leave the resulting string still too long.
2767+
*/
27532768
name += name_len - len;
27542769
slash = strchr(name, '/');
27552770
if (slash)

0 commit comments

Comments
 (0)