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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Fri, 23 Feb 2007, Junio C Hamano wrote:

> -	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 == '/'));

I briefly thought about something like this instead:

-	a_one = quote_two("a/", name_a + (*name_a == '/'));
-	b_two = quote_two("b/", name_b + (*name_b == '/'));
+	a_one = quote_two(*name_a == '/' ? "" : "a/", name_a);
+	b_two = quote_two(*name_b == '/' ? "" : "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);
+	printf("%sdiff %s%s %s%s\n", set, *name_a == '/' || *name_b == '/' ?
+			"" : "--git ", a_one, b_two, reset);

but I think your approach is better.

Ciao,
Dscho

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]