git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] Provide a way to flush git-diff-tree's output
@ 2006-05-18  6:58 Paul Mackerras
  2006-05-18  7:24 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Mackerras @ 2006-05-18  6:58 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git

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;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Provide a way to flush git-diff-tree's output
  2006-05-18  6:58 [PATCH] Provide a way to flush git-diff-tree's output Paul Mackerras
@ 2006-05-18  7:24 ` Junio C Hamano
  2006-05-18  9:43   ` Paul Mackerras
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2006-05-18  7:24 UTC (permalink / raw
  To: Paul Mackerras; +Cc: git

Paul Mackerras <paulus@samba.org> writes:

> 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.

Sounds low impact and sane.

I suspect the usual caveat on bidirectional pipe deadlock
applies to the caller.  Does gitk do that?  The current code
seems to feed a pre-generated list with "open | cmd <<"
construct to the command, so perhaps you are planning to change
that?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Provide a way to flush git-diff-tree's output
  2006-05-18  7:24 ` Junio C Hamano
@ 2006-05-18  9:43   ` Paul Mackerras
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Mackerras @ 2006-05-18  9:43 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git

Junio C Hamano writes:

> Sounds low impact and sane.
> 
> I suspect the usual caveat on bidirectional pipe deadlock
> applies to the caller.  Does gitk do that?  The current code

Gitk will use non-blocking mode on the pipes to/from the git-diff-tree
process, so there isn't a possibility of deadlock that I can see.

> seems to feed a pre-generated list with "open | cmd <<"
> construct to the command, so perhaps you are planning to change
> that?

That's for the "Find" function.  I'm in the process of adding the code
to let users enter a list of paths and have gitk highlight the commits
affecting those paths.  That will involve a separate invocation of
git-diff-tree.  To make it responsive, I'm only going to ask
git-diff-tree about the commits that are visible on the screen - but I
need git-diff-tree to give me an answer quickly, i.e. in less time
than a human can perceive.

Thanks,
Paul.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-05-18  9:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-18  6:58 [PATCH] Provide a way to flush git-diff-tree's output Paul Mackerras
2006-05-18  7:24 ` Junio C Hamano
2006-05-18  9:43   ` Paul Mackerras

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).