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

[PATCH] git-diff-cache: handle pathspec beginning with a dash

From
Jonas Fonseca <fonseca@diku.dk>
Date
Jun 6, 2005, 21:27 UTC
Message-ID
<20050606212700.GA3498@diku.dk>
Parse everything after '--' as tree name or pathspec.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
 diff-cache.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/diff-cache.c b/diff-cache.c
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -167,13 +167,14 @@ int main(int argc, const char **argv)
 	void *tree;
 	unsigned long size;
 	int ret;
+	int allow_options = 1;
 	int i;
 
 	read_cache();
 	for (i = 1; i < argc; i++) {
 		const char *arg = argv[i];
 
-		if (*arg != '-') {
+		if (!allow_options || *arg != '-') {
 			if (tree_name) {
 				pathspec = argv + i;
 				break;
@@ -182,6 +183,10 @@ int main(int argc, const char **argv)
 			continue;
 		}
 			
+		if (!strcmp(arg, "--")) {
+			allow_options = 0;
+			continue;
+		}
 		if (!strcmp(arg, "-r")) {
 			/* We accept the -r flag just to look like git-diff-tree */
 			continue;
-- 
Jonas Fonseca
Next: Jonas Fonseca
Message 1 of 6 in “git-diff-cache: handle pathspec beginning with a dash”
  1. git-diff-cache: handle pathspec beginning with a dashJonas Fonseca, Jun 6, 2005
  2. cg-commit: prefix pathspec argument with --Jonas Fonseca, Jun 6, 2005
  3. Petr BaudisJun 8, 2005
  4. Linus TorvaldsJun 8, 2005
  5. Petr BaudisJun 8, 2005
  6. Linus TorvaldsJun 8, 2005

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.