@matheusbsbs / matheus-bagliano / commits / 5089277718
Fork 0

diff-patch: Avoid emitting double-slashes in textual patch.

Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Feb 23, 2007 at 03:44 UTC 5089277718503a4de7817b5f6754cb03116d5524
1 file changed +4 -2
diff.c
+4 -2
@@ -211,6 +211,8 @@ static void emit_rewrite_diff(const char *name_a,
211 diff_populate_filespec(two, 0);
212 lc_a = count_lines(one->data, one->size);
213 lc_b = count_lines(two->data, two->size);
214 + name_a += (*name_a == '/');
215 + name_b += (*name_b == '/');
216 printf("--- a/%s\n+++ b/%s\n@@ -", name_a, name_b);
217 print_line_count(lc_a);
218 printf(" +");
@@ -1020,8 +1022,8 @@ static void builtin_diff(const char *name_a,
1022 const char *set = diff_get_color(o->color_diff, DIFF_METAINFO);
1023 const char *reset = diff_get_color(o->color_diff, DIFF_RESET);
1024
1023 - a_one = quote_two("a/", name_a);
1024 - b_two = quote_two("b/", name_b);
1025 + a_one = quote_two("a/", name_a + (*name_a == '/'));
1026 + b_two = quote_two("b/", name_b + (*name_b == '/'));
1027 lbl[0] = DIFF_FILE_VALID(one) ? a_one : "/dev/null";
1028 lbl[1] = DIFF_FILE_VALID(two) ? b_two : "/dev/null";
1029 printf("%sdiff --git %s %s%s\n", set, a_one, b_two, reset);