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

[PATCH 2/2] diffcore-pickaxe: terminate grepping as soon as it hits

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Aug 15, 2011, 02:41 UTC
Message-ID
<1313376083-24713-2-git-send-email-pclouds@gmail.com>
In-Reply-To
<1313376083-24713-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 diffcore-pickaxe.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index 12811b9..e028dd5 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -21,11 +21,7 @@ static int diffgrep_consume(void *priv, char *line, unsigned long len)
 	if (line[0] != '+' && line[0] != '-')
 		return 0;
 	if (data->hit)
-		/*
-		 * NEEDSWORK: we should have a way to terminate the
-		 * caller early.
-		 */
-		return 0;
+		return -1;
 	/* Yuck -- line ought to be "const char *"! */
 	hold = line[len];
 	line[len] = '\0';
-- 
1.7.4.74.g639db
Previous: Nguyễn Thái Ngọc DuyNext: Nguyen Thai Ngoc Duy
Message 2 of 5 in “xdiff-interface: allow consume function to quit early by returning non-zero”
  1. 1/2 xdiff-interface: allow consume function to quit early by returning non-zeroNguyễn Thái Ngọc Duy, Aug 15, 2011
  2. 2/2 diffcore-pickaxe: terminate grepping as soon as it hitsNguyễn Thái Ngọc Duy, Aug 15, 2011
  3. Nguyen Thai Ngoc DuyAug 17, 2011
  4. Junio C HamanoAug 15, 2011
  5. Nguyen Thai Ngoc DuyAug 17, 2011

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.