commit 4adf9a5039c8b1ceaf7020883aa9d00d8bcf17610c7bad027c74ef82da626a00 from: Stefan Sperling date: Tue Mar 10 11:35:48 2026 UTC expand tab characters in log messages displayed by tog diff Ever since tog started indenting the log message by one space character, lines containing tab characters ended up using wrong indentation. Fix this by expanding tabs to spaces before applying extra indentation. To see the effect of this fix, start tog in diff.git as follows: tog diff -c dc306c6bd88271ab911e205539974da98be82d17 commit - c52931e3617c3dce87bce08dc21e14d45ba5cb177b82c888dddfc20e88147d9e commit + 4adf9a5039c8b1ceaf7020883aa9d00d8bcf17610c7bad027c74ef82da626a00 blob - 0645d957d1b5ca92447917beba39af5d7c255097ebdb283447f4f400bcdab9f4 blob + b0008e8087d94e7cbb75cff81f26de5d6256667cd568614aff73eef0adb3fe2d --- tog/tog.c +++ tog/tog.c @@ -5938,7 +5938,7 @@ write_commit_info(struct got_diff_line **lines, size_t char *id_str = NULL, *logmsg = NULL, *s = NULL, *line; time_t committer_time; const char *author, *committer; - char *refs_str = NULL; + char *refs_str = NULL, *exstr = NULL; off_t outoff = 0; int n; @@ -6039,11 +6039,16 @@ write_commit_info(struct got_diff_line **lines, size_t goto done; s = logmsg; while ((line = strsep(&s, "\n")) != NULL) { - n = fprintf(outfile, " %s\n", line); + err = expand_tab(&exstr, line); + if (err) + goto done; + n = fprintf(outfile, " %s\n", exstr); if (n < 0) { err = got_error_from_errno("fprintf"); goto done; } + free(exstr); + exstr = NULL; outoff += n; err = add_line_metadata(lines, nlines, outoff, GOT_DIFF_LINE_LOGMSG); @@ -6052,6 +6057,7 @@ write_commit_info(struct got_diff_line **lines, size_t } done: + free(exstr); free(id_str); free(logmsg); free(refs_str);