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

Re: [PATCH] git-rev-list --help anywhere

From
Alex Riesen <raa.lkml@gmail.com>
Date
Feb 19, 2006, 18:39 UTC
Message-ID
<20060219183930.GB10010@steel.home>
In-Reply-To
<20060219112627.18989.qmail@science.horizon.com>
linux@horizon.com, Sun, Feb 19, 2006 12:26:27 +0100:
Show 15 quoted lines
> >+	for (i = 1 ; i < argc; i++)
> >+	    if ( !strcmp(argv[i], "--help") )
> >+		usage(rev_list_usage);
> 
> You might want to try something more like:
> 
> +	for (i = 1 ; i < argc; i++) {
> +	    if ( !strcmp(argv[i], "--help") )
> +		usage(rev_list_usage);
> +	    if ( !strcmp(argv[i], "--") )
> +		break;
> +	}
> 
> So that you don't break in the perverse but legal case of
> having a file named "--help".
Of course. Thanks!
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
diff --git a/rev-list.c b/rev-list.c
index f2d1105..bcb492e 100644
--- a/rev-list.c
+++ b/rev-list.c
@@ -755,11 +755,20 @@ static void handle_all(struct commit_lis
 
 int main(int argc, const char **argv)
 {
-	const char *prefix = setup_git_directory();
+	const char *prefix;
 	struct commit_list *list = NULL;
 	int i, limited = 0;
 
 	for (i = 1 ; i < argc; i++) {
+	    if ( !strcmp(argv[i], "--help") )
+		usage(rev_list_usage);
+	    if ( !strcmp(argv[i], "--") )
+		break;
+	}
+
+	prefix = setup_git_directory();
+
+	for (i = 1 ; i < argc; i++) {
 		int flags;
 		const char *arg = argv[i];
 		char *dotdot;
--
1.2.2.gbc57
Previous: linux@horizon.comNext: Johannes Schindelin
Message 2 of 6 in “Re: [PATCH] git-rev-list --help anywhere”
  1. linux@horizon.comFeb 19, 2006
  2. Alex RiesenFeb 19, 2006
  3. Johannes SchindelinFeb 19, 2006
  4. linux@horizon.comFeb 19, 2006
  5. A Large Angry SCMFeb 19, 2006
  6. Junio C HamanoFeb 20, 2006

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.