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

Re: Bug: problem with file named with dash character

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 27, 2012, 20:33 UTC
Message-ID
<7vbok48pfu.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vfw9g8pqn.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 8 quoted lines
> Jeff King <peff@peff.net> writes:
>
>> but that code path should be fixed properly (with a use_stdin flag in
>> the filespec).
>
> Yes, just as I said; I am finding more and more issues with the
> no-index hack that I have been fixing a bit by bit since I send the
> message you responded to.
It is not ready yet, but here are a few patches WIP.
-- >8 --
From: Junio C Hamano <gitster@pobox.com>
Date: Wed, 27 Jun 2012 11:51:15 -0700
Subject: [PATCH 1/?] diff-index.c: do not pretend paths are pathspecs

"git diff --no-index" takes exactly two paths, not pathspecs, and has its own way queue_diff() to populate the diff_queue. Do not call diff_tree_setup_paths(), pretending as it takes pathspecs.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 diff-no-index.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/diff-no-index.c b/diff-no-index.c
index f0b0010..ca875da 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -175,6 +175,7 @@ void diff_no_index(struct rev_info *revs,
 	int i;
 	int no_index = 0;
 	unsigned options = 0;
+	const char *paths[2];
 
 	/* Were we asked to do --no-index explicitly? */
 	for (i = 1; i < argc; i++) {
@@ -233,8 +234,6 @@ void diff_no_index(struct rev_info *revs,
 
 	if (prefix) {
 		int len = strlen(prefix);
-		const char *paths[3];
-		memset(paths, 0, sizeof(paths));
 
 		for (i = 0; i < 2; i++) {
 			const char *p = argv[argc - 2 + i];
@@ -247,10 +246,10 @@ void diff_no_index(struct rev_info *revs,
 			     : p);
 			paths[i] = p;
 		}
-		diff_tree_setup_paths(paths, &revs->diffopt);
+	} else {
+		for (i = 0; i < 2; i++)
+			paths[i] = argv[argc - 2 + i];
 	}
-	else
-		diff_tree_setup_paths(argv + argc - 2, &revs->diffopt);
 	revs->diffopt.skip_stat_unmatch = 1;
 	if (!revs->diffopt.output_format)
 		revs->diffopt.output_format = DIFF_FORMAT_PATCH;
@@ -262,8 +261,7 @@ void diff_no_index(struct rev_info *revs,
 	if (diff_setup_done(&revs->diffopt) < 0)
 		die("diff_setup_done failed");
 
-	if (queue_diff(&revs->diffopt, revs->diffopt.pathspec.raw[0],
-		       revs->diffopt.pathspec.raw[1]))
+	if (queue_diff(&revs->diffopt, paths[0], paths[1]))
 		exit(1);
 	diff_set_mnemonic_prefix(&revs->diffopt, "1/", "2/");
 	diffcore_std(&revs->diffopt);
-- 
1.7.11.1.184.g3ee8f69
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 13 in “Bug: problem with file named with dash character”
  1. Daniel Lyubomirov -|- Digitalus BulgariaJun 27, 2012
  2. faux@goeswhere.comJun 27, 2012
  3. Junio C HamanoJun 27, 2012
  4. Jeff KingJun 27, 2012
  5. Jeff KingJun 27, 2012
  6. Junio C HamanoJun 27, 2012
  7. Junio C HamanoJun 27, 2012
  8. Junio C HamanoJun 27, 2012
  9. Junio C HamanoJun 27, 2012
  10. Junio C HamanoJun 27, 2012
  11. Jeff KingJun 27, 2012
  12. Junio C HamanoJun 27, 2012
  13. Jeff KingJun 27, 2012

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.