summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-12-27 01:13:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-12-27 01:13:36 (GMT)
commitd56250911f4ec074048f4edb34551eaf384172cc (patch)
tree8978a2314f00add8f84a9164ba69da2fb70c9aeb /diff.c
parent462a15bc82e6adbcb8db5fcc4791ec70a026aa4b (diff)
downloadgit-d56250911f4ec074048f4edb34551eaf384172cc.zip
git-d56250911f4ec074048f4edb34551eaf384172cc.tar.gz
git-d56250911f4ec074048f4edb34551eaf384172cc.tar.bz2
Fix rewrite_diff() name quoting.
This moves the logic to quote two paths (prefix + path) in C-style introduced in the previous commit from the dump_quoted_path() in combine-diff.c to quote.c, and uses it to fix rewrite_diff() that never C-quoted the pathnames correctly. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/diff.c b/diff.c
index 61fd492..5bdc111 100644
--- a/diff.c
+++ b/diff.c
@@ -300,19 +300,25 @@ static void emit_rewrite_diff(const char *name_a,
const char *old = diff_get_color(color_diff, DIFF_FILE_OLD);
const char *new = diff_get_color(color_diff, DIFF_FILE_NEW);
const char *reset = diff_get_color(color_diff, DIFF_RESET);
+ static struct strbuf a_name = STRBUF_INIT, b_name = STRBUF_INIT;
name_a += (*name_a == '/');
name_b += (*name_b == '/');
name_a_tab = strchr(name_a, ' ') ? "\t" : "";
name_b_tab = strchr(name_b, ' ') ? "\t" : "";
+ strbuf_reset(&a_name);
+ strbuf_reset(&b_name);
+ quote_two_c_style(&a_name, o->a_prefix, name_a, 0);
+ quote_two_c_style(&b_name, o->b_prefix, name_b, 0);
+
diff_populate_filespec(one, 0);
diff_populate_filespec(two, 0);
lc_a = count_lines(one->data, one->size);
lc_b = count_lines(two->data, two->size);
- printf("%s--- %s%s%s%s\n%s+++ %s%s%s%s\n%s@@ -",
- metainfo, o->a_prefix, name_a, name_a_tab, reset,
- metainfo, o->b_prefix, name_b, name_b_tab, reset, fraginfo);
+ printf("%s--- %s%s%s\n%s+++ %s%s%s\n%s@@ -",
+ metainfo, a_name.buf, name_a_tab, reset,
+ metainfo, b_name.buf, name_b_tab, reset, fraginfo);
print_line_count(lc_a);
printf(" +");
print_line_count(lc_b);