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

[PATCH 05/12] check_connected: relay errors to alternate descriptor

From
Jeff King <peff@peff.net>
Date
Jul 15, 2016, 10:32 UTC
Message-ID
<20160715103203.GE19271@sigill.intra.peff.net>
In-Reply-To
<20160715102506.GA23164@sigill.intra.peff.net>

Unless the "quiet" flag is given, check_connected sends any errors to the stderr of the caller (because the child rev-list inherits that descriptor). However, server-side callers may want to send these over a sideband channel instead. Let's make that possible.

Signed-off-by: Jeff King <peff@peff.net>
---
 connected.c | 11 +++++++++--
 connected.h |  7 +++++++
 2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/connected.c b/connected.c
index 2a51eac..5f5c8bd 100644
--- a/connected.c
+++ b/connected.c
@@ -31,8 +31,11 @@ int check_connected(sha1_iterate_fn fn, void *cb_data,
 		opt = &defaults;
 	transport = opt->transport;
 
-	if (fn(cb_data, sha1))
+	if (fn(cb_data, sha1)) {
+		if (opt->err_fd)
+			close(opt->err_fd);
 		return err;
+	}
 
 	if (transport && transport->smart_options &&
 	    transport->smart_options->self_contained_and_connected &&
@@ -59,7 +62,11 @@ int check_connected(sha1_iterate_fn fn, void *cb_data,
 	rev_list.git_cmd = 1;
 	rev_list.in = -1;
 	rev_list.no_stdout = 1;
-	rev_list.no_stderr = opt->quiet;
+	if (opt->err_fd)
+		rev_list.err = opt->err_fd;
+	else
+		rev_list.no_stderr = opt->quiet;
+
 	if (start_command(&rev_list))
 		return error(_("Could not run 'git rev-list'"));
 
diff --git a/connected.h b/connected.h
index 12594ef..5d88e26 100644
--- a/connected.h
+++ b/connected.h
@@ -23,6 +23,13 @@ struct check_connected_options {
 
 	/* Transport whose objects we are checking, if available. */
 	struct transport *transport;
+
+	/*
+	 * If non-zero, send error messages to this descriptor rather
+	 * than stderr. The descriptor is closed before check_connected
+	 * returns.
+	 */
+	int err_fd;
 };
 
 #define CHECK_CONNECTED_INIT { 0 }
-- 
2.9.1.434.g748be50
Previous: Jeff KingNext: Junio C Hamano
Message 10 of 26 in “push progress reporting and keepalives”
  1. 0/12 push progress reporting and keepalivesJeff King, Jul 15, 2016
  2. 01/12 check_everything_connected: always pass --quiet to rev-listJeff King, Jul 15, 2016
  3. 02/12 rev-list: add optional progress reportingJeff King, Jul 15, 2016
  4. Junio C HamanoJul 15, 2016
  5. Jeff KingJul 16, 2016
  6. 03/12 check_everything_connected: convert to argv_arrayJeff King, Jul 15, 2016
  7. 04/12 check_everything_connected: use a struct with named optionsJeff King, Jul 15, 2016
  8. Junio C HamanoJul 15, 2016
  9. Jeff KingJul 16, 2016
  10. 05/12 check_connected: relay errors to alternate descriptorJeff King, Jul 15, 2016
  11. Junio C HamanoJul 15, 2016
  12. Jeff KingJul 16, 2016
  13. 06/12 check_connected: add progress flagJeff King, Jul 15, 2016
  14. 07/12 clone: use a real progress meter for connectivity checkJeff King, Jul 15, 2016
  15. 08/12 index-pack: add flag for showing delta-resolution progressJeff King, Jul 15, 2016
  16. 09/12 receive-pack: turn on index-pack resolving progressJeff King, Jul 15, 2016
  17. 10/12 receive-pack: relay connectivity errors to sidebandJeff King, Jul 15, 2016
  18. 11/12 receive-pack: turn on connectivity progressJeff King, Jul 15, 2016
  19. 12/12 receive-pack: send keepalives during quiet periodsJeff King, Jul 15, 2016
  20. Stefan BellerJul 15, 2016
  21. Jeff KingJul 16, 2016
  22. Stefan BellerJul 19, 2016
  23. Jeff KingJul 19, 2016
  24. Stefan BellerJul 19, 2016
  25. Jeff KingJul 20, 2016
  26. Junio C HamanoJul 15, 2016

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.