summaryrefslogtreecommitdiff
path: root/merge-blobs.c
diff options
context:
space:
mode:
authorGreg Hurrell <greg.hurrell@datadoghq.com>2025-08-11 11:55:23 +0000
committerJunio C Hamano <gitster@pobox.com>2025-08-11 08:58:21 -0700
commit621ce9c1c6cfe5a6467ef62cb81992b3a318b70e (patch)
tree32caefef29868809ce5b24f23b02ad07c644996a /merge-blobs.c
parentfbe8d3079d4a96aeb4e4529cc93cc0043b759a05 (diff)
git-jump: make `diff` work with filenames containing spaces
In diff.c, we output a trailing "\t" at the end of any filename that contains a space: case DIFF_SYMBOL_FILEPAIR_PLUS: meta = diff_get_color_opt(o, DIFF_METAINFO); reset = diff_get_color_opt(o, DIFF_RESET); fprintf(o->file, "%s%s+++ %s%s%s\n", diff_line_prefix(o), meta, line, reset, strchr(line, ' ') ? "\t" : ""); break; That is, for a file "foo.txt", `git diff --no-prefix` will emit: +++ foo.txt but for "foo bar.txt" it will emit: +++ foo bar.txt\t This in turn leads `git-jump` to produce a quickfix format like this: foo bar.txt\t:1:1:contents Because no "foo bar.txt\t" file actually exists on disk, opening it in Vim will just land the user in an empty buffer. This commit takes the simple approach of unconditionally stripping any trailing tab. Consider the following three examples: 1. For file "foo", Git will emit "foo". 2. For file "foo bar", Git will emit "foo bar\t". 3. For file "foo\t", Git will emit "\"foo\t\"". 4. For file "foo bar\t", Git will emit "\"foo bar\t\"". Before this commit, `git-jump` correctly handled only case "1". After this commit, `git-jump` correctly handles cases "1" and "2". In reality, these are the only cases people are going to run into with any regularity, and the other two are rare edge cases, which probably aren't worth the effort to support unless somebody actually complains about them. Signed-off-by: Greg Hurrell <greg.hurrell@datadoghq.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-blobs.c')
0 files changed, 0 insertions, 0 deletions