Re: git clone silently aborts if stdout gets a broken pipe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 18, 2013 at 06:52:13PM +0200, Peter Kjellerstedt wrote:

> The failing Perl code used a construct like this:
> 
> 	Git::command_oneline('clone', $url, $path);
> 
> There is no error raised, but the directory specified by 
> $path is not created. If I look at the process using strace 
> I can see the clone taking place, but then it seems to get 
> a broken pipe since the code above only cares about the 
> first line from stdout (and with the addition of "Checking 
> connectivity..." git clone now outputs two lines to stdout).

I think your perl script is somewhat questionable, as it is making
assumptions about the output of git-clone, and you would do better to
accept arbitrary-sized output (or better yet, leave stdout pointing to
the user, so they can see the output, which is meant for them).

That being said, the new messages should almost certainly go to stderr.

-- >8 --
Subject: [PATCH] clone: write "checking connectivity" to stderr

In commit 0781aa4 (clone: let the user know when
check_everything_connected is run, 2013-05-03), we started
giving the user a progress report during clone. However,
since the actual work happens in a sub-process, we do not
use the usual progress code that counts the objects, but
rather just print a message ourselves.

This message goes to stdout via printf, which is unlike
other progress messages (both the eye candy within clone,
and the "checking connectivity" progress in other commands).
Let's send it to stderr for consistency.

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
 builtin/clone.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index ca3eb68..3c91844 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -551,12 +551,12 @@ static void update_remote_refs(const struct ref *refs,
 
 	if (check_connectivity) {
 		if (0 <= option_verbosity)
-			printf(_("Checking connectivity... "));
+			fprintf(stderr, _("Checking connectivity... "));
 		if (check_everything_connected_with_transport(iterate_ref_map,
 							      0, &rm, transport))
 			die(_("remote did not send all necessary objects"));
 		if (0 <= option_verbosity)
-			printf(_("done\n"));
+			fprintf(stderr, _("done\n"));
 	}
 
 	if (refs) {
-- 
1.8.4.rc4.16.g228394f

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]