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

[PATCH] Provide a way to flush git-diff-tree's output

From
Paul Mackerras <paulus@samba.org>
Date
May 18, 2006, 06:58 UTC
Message-ID
<17516.6955.282732.460675@cargo.ozlabs.ibm.com>

Gitk wants to use git-diff-tree as a filter to tell it which ids from a given list affect a set of files or directories. We don't want to fork and exec a new git-diff-tree process for each batch of ids, since there could be a lot of relatively small batches. For example, a batch could contain as many ids as fit in gitk's headline display window, i.e. 20 or so, and we would be processing a new batch every time the user scrolls that window.

The --stdin flag to git-diff-tree is suitable for this, but the main difficulty is that the output of git-diff-tree gets buffered and doesn't get sent until the buffer is full.

This provides a way to get git-diff-tree to flush its output buffers. If a blank line is supplied on git-diff-tree's standard input, it will flush its output buffers and then accept further input.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
diff --git a/diff-tree.c b/diff-tree.c
index 7207867..69bb74b 100644
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -138,7 +138,10 @@ int main(int argc, const char **argv)
 		opt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |
 				       DIFF_SETUP_USE_CACHE);
 	while (fgets(line, sizeof(line), stdin))
-		diff_tree_stdin(line);
+		if (line[0] == '\n')
+			fflush(stdout);
+		else
+			diff_tree_stdin(line);
 
 	return 0;
 }
Next: Junio C Hamano
Message 1 of 3 in “Provide a way to flush git-diff-tree's output”
  1. Provide a way to flush git-diff-tree's outputPaul Mackerras, May 18, 2006
  2. Junio C HamanoMay 18, 2006
  3. Paul MackerrasMay 18, 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.