threads / patch / 13785

patchcat-file --batch: flush stdout also when objects are missing

Subject: [PATCH] cat-file --batch: flush stdout also when objects are missing

## tl;dr

2 messages between Jun 3, 2008 and Jun 3, 2008. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Lea Wiemann· Jun 3, 2008, 18:34 UTC · lore

cat-file --batch/--batch-check only flushes stdout when the object exists, but not when it doesn't ("<object> missing"). This makes bidirectional pipes hang.

Signed-off-by: Lea Wiemann <LeWiemann@gmail.com>
---
 builtin-cat-file.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to builtin-cat-file.c +1 −0
diff --git a/builtin-cat-file.c b/builtin-cat-file.c
index 200345e..f8b3160 100644
--- a/builtin-cat-file.c
+++ b/builtin-cat-file.c
@@ -159,6 +159,7 @@ static int batch_one_object(const char *obj_name, int print_contents)
 
 	if (get_sha1(obj_name, sha1)) {
 		printf("%s missing\n", obj_name);
+		fflush(stdout);
 		return 0;
 	}
 
-- 
1.5.6.rc0.92.g27fd.dirty
Junio C Hamano· Jun 3, 2008, 19:40 UTC · re: Lea Wiemann · lore

Re: [PATCH] cat-file --batch: flush stdout also when objects are missing

Lea Wiemann <lewiemann@gmail.com> writes:
Show 23 quoted lines
> cat-file --batch/--batch-check only flushes stdout when the object
> exists, but not when it doesn't ("<object> missing").  This makes
> bidirectional pipes hang.
>
> Signed-off-by: Lea Wiemann <LeWiemann@gmail.com>
> ---
>  builtin-cat-file.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/builtin-cat-file.c b/builtin-cat-file.c
> index 200345e..f8b3160 100644
> --- a/builtin-cat-file.c
> +++ b/builtin-cat-file.c
> @@ -159,6 +159,7 @@ static int batch_one_object(const char *obj_name, int print_contents)
>  
>  	if (get_sha1(obj_name, sha1)) {
>  		printf("%s missing\n", obj_name);
> +		fflush(stdout);
>  		return 0;
>  	}
>  
> -- 
> 1.5.6.rc0.92.g27fd.dirty
Ah, good catch.
Thanks.

← back to recent threads