summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <junkio@cox.net>2007-02-23 03:44:30 -0800
committerLibravatar Junio C Hamano <junkio@cox.net>2007-02-24 01:26:52 -0800
commit5089277718503a4de7817b5f6754cb03116d5524 (patch)
tree212ca5bff10434efcbc977763b2b9dd781917785
parentReword git-am 3-way fallback failure message. (diff)
downloadtgif-5089277718503a4de7817b5f6754cb03116d5524.tar.xz
diff-patch: Avoid emitting double-slashes in textual patch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--diff.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index 13b9b6c560..b8a90e91a9 100644
--- a/diff.c
+++ b/diff.c
@@ -211,6 +211,8 @@ static void emit_rewrite_diff(const char *name_a,
diff_populate_filespec(two, 0);
lc_a = count_lines(one->data, one->size);
lc_b = count_lines(two->data, two->size);
+ name_a += (*name_a == '/');
+ name_b += (*name_b == '/');
printf("--- a/%s\n+++ b/%s\n@@ -", name_a, name_b);
print_line_count(lc_a);
printf(" +");
@@ -1020,8 +1022,8 @@ static void builtin_diff(const char *name_a,
const char *set = diff_get_color(o->color_diff, DIFF_METAINFO);
const char *reset = diff_get_color(o->color_diff, DIFF_RESET);
- a_one = quote_two("a/", name_a);
- b_two = quote_two("b/", name_b);
+ a_one = quote_two("a/", name_a + (*name_a == '/'));
+ b_two = quote_two("b/", name_b + (*name_b == '/'));
lbl[0] = DIFF_FILE_VALID(one) ? a_one : "/dev/null";
lbl[1] = DIFF_FILE_VALID(two) ? b_two : "/dev/null";
printf("%sdiff --git %s %s%s\n", set, a_one, b_two, reset);