git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 23, 2007, 16:07 UTC
Message-ID
<Pine.LNX.4.63.0702231705370.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vmz353xpd.fsf@assigned-by-dhcp.cox.net>
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

Previous: Junio C Hamano
Message 13 of 13 in “Teach git-diff{,-files} the new option `--no-index`”
  1. Teach git-diff{,-files} the new option `--no-index`Johannes Schindelin, Feb 20, 2007
  2. Junio C HamanoFeb 22, 2007
  3. Johannes SchindelinFeb 22, 2007
  4. Junio C HamanoFeb 22, 2007
  5. Johannes SchindelinFeb 22, 2007
  6. run_diff_files(): add option to prevent --no-indexJohannes Schindelin, Feb 22, 2007
  7. Junio C HamanoFeb 22, 2007
  8. Johannes SchindelinFeb 22, 2007
  9. Junio C HamanoFeb 22, 2007
  10. Johannes SchindelinFeb 22, 2007
  11. Teach git-diff-files the new option `--no-index`Johannes Schindelin, Feb 22, 2007
  12. Junio C HamanoFeb 23, 2007
  13. Johannes SchindelinFeb 23, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.