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

Re: [PATCH] connected.c: reprepare packs for corner cases

From
Jeff King <peff@peff.net>
Date
Mar 12, 2020, 21:26 UTC
Message-ID
<20200312212613.GB872402@coredump.intra.peff.net>
In-Reply-To
<20200312211638.GA872402@coredump.intra.peff.net>
On Thu, Mar 12, 2020 at 05:16:38PM -0400, Jeff King wrote:
> There we see that same reprepare happen in 882839, which is the child
> fetch-pack. The parent fetch probably needs to reprepare itself after
> fetch-pack completes.

Actually, it's not fetch which is running fetch-pack, but rather the remote helper itself. So I think the simplest thing is for the remote-helper layer to do something like this:

diff --git a/transport-helper.c b/transport-helper.c
index 20a7185ec4..25957e9a05 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -14,6 +14,7 @@
 #include "refspec.h"
 #include "transport-internal.h"
 #include "protocol.h"
+#include "packfile.h"
 
 static int debug;
 
@@ -672,6 +673,7 @@ static int fetch(struct transport *transport,
 {
 	struct helper_data *data = transport->data;
 	int i, count;
+	int ret;
 
 	get_helper(transport);
 
@@ -710,13 +712,18 @@ static int fetch(struct transport *transport,
 	if (data->transport_options.negotiation_tips)
 		warning("Ignoring --negotiation-tip because the protocol does not support it.");
 
-	if (data->fetch)
-		return fetch_with_fetch(transport, nr_heads, to_fetch);
+	ret = data->fetch ? fetch_with_fetch(transport, nr_heads, to_fetch) :
+	      data->import ? fetch_with_import(transport, nr_heads, to_fetch) :
+	      -1;
 
-	if (data->import)
-		return fetch_with_import(transport, nr_heads, to_fetch);
+	/*
+	 * We may have just received a pack through the helper sub-process;
+	 * refresh the pack list.
+	 */
+	if (!ret)
+		reprepare_packed_git(the_repository);
 
-	return -1;
+	return ret;
 }
 
 static int push_update_ref_status(struct strbuf *buf,
Previous: Jeff KingNext: Derrick Stolee
Message 6 of 12 in “connected.c: reprepare packs for corner cases”
  1. connected.c: reprepare packs for corner casesDerrick Stolee via GitGitGadget, Mar 12, 2020
  2. Jonathan TanMar 12, 2020
  3. Derrick StoleeMar 12, 2020
  4. Junio C HamanoMar 12, 2020
  5. Jeff KingMar 12, 2020
  6. Jeff KingMar 12, 2020
  7. Derrick StoleeMar 13, 2020
  8. Junio C HamanoMar 13, 2020
  9. Jeff KingMar 13, 2020
  10. Jeff KingMar 13, 2020
  11. Derrick StoleeMar 13, 2020
  12. connected.c: reprepare packs for corner casesDerrick Stolee via GitGitGadget, Mar 13, 2020

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.