X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=combine-diff.c;h=aa9d79ea0bf011ea45ef629ef713e6c977781431;hb=3e5970a41ec0809efb792357af546ffa96568f66;hp=9f80a1c5e3a461afd11966625589684d61187911;hpb=abf7e0df170d957d973f74b08a898be114d1b228;p=git.git diff --git a/combine-diff.c b/combine-diff.c index 9f80a1c5e..aa9d79ea0 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -500,6 +500,18 @@ static int hunk_comment_line(const char *bol) return (isalpha(ch) || ch == '_' || ch == '$'); } +static void show_line_to_eol(const char *line, int len, const char *reset) +{ + int saw_cr_at_eol = 0; + if (len < 0) + len = strlen(line); + saw_cr_at_eol = (len && line[len-1] == '\r'); + + printf("%.*s%s%s\n", len - saw_cr_at_eol, line, + reset, + saw_cr_at_eol ? "\r" : ""); +} + static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent, int use_color) { @@ -593,7 +605,7 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent, else putchar(' '); } - printf("%s%s\n", ll->line, c_reset); + show_line_to_eol(ll->line, -1, c_reset); ll = ll->next; } if (cnt < lno) @@ -617,7 +629,7 @@ static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent, putchar(' '); p_mask <<= 1; } - printf("%.*s%s\n", sl->len, sl->bol, c_reset); + show_line_to_eol(sl->bol, sl->len, c_reset); } } } @@ -727,6 +739,18 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent, die("early EOF '%s'", elem->path); result[len] = 0; + + /* If not a fake symlink, apply filters, e.g. autocrlf */ + if (is_file) { + struct strbuf buf; + + strbuf_init(&buf, 0); + if (convert_to_git(elem->path, result, len, &buf, safe_crlf)) { + free(result); + result = strbuf_detach(&buf, &len); + result_size = len; + } + } } else { deleted_file: