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

[PATCH] diff --no-index -q: fix endless loop

From
Thomas Rast <trast@student.ethz.ch>
Date
Jan 7, 2009, 11:15 UTC
Message-ID
<1231326930-7132-1-git-send-email-trast@student.ethz.ch>
In-Reply-To
<7veizfbnuw.fsf@gitster.siamese.dyndns.org>

We forgot to move to the next argument when parsing -q, getting stuck in an endless loop.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
Junio C Hamano wrote:
> I'll queue the "--" fix, "-q" fix and this pager fix.  Thanks.

Seems the after-midnight rule indeed has some value. I pointed out the argv[i] bug, which I see you have squashed into the -- fix, but failed to notice that the -q parsing is also missing an i++.

I'm still not convinced of the option's value, but this patch at least fixes the bug.

 diff-no-index.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/diff-no-index.c b/diff-no-index.c
index 12ff1f1..60ed174 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -207,8 +207,10 @@ void diff_no_index(struct rev_info *revs,
 		int j;
 		if (!strcmp(argv[i], "--no-index"))
 			i++;
-		else if (!strcmp(argv[i], "-q"))
+		else if (!strcmp(argv[i], "-q")) {
 			options |= DIFF_SILENT_ON_REMOVED;
+			i++;
+		}
 		else if (!strcmp(argv[i], "--"))
 			i++;
 		else {
-- 
tg: (3bbe36c..) t/diff-q-endless (depends on: next)
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 8 in “diff --no-index: test for pager after option parsing”
  1. diff --no-index: test for pager after option parsingThomas Rast, Jan 6, 2009
  2. Thomas RastJan 7, 2009
  3. Junio C HamanoJan 7, 2009
  4. Miklos VajnaJan 7, 2009
  5. Jeff KingJan 7, 2009
  6. Junio C HamanoJan 7, 2009
  7. diff --no-index -q: fix endless loopThomas Rast, Jan 7, 2009
  8. Junio C HamanoJan 7, 2009

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.