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

[PATCH] clone: check if server supports shallow clones

From
Mike Edgar <adgar@google.com>
Date
Jun 10, 2015, 18:35 UTC
Message-ID
<1433961320-1366-1-git-send-email-adgar@google.com>

When the user passes --depth to git-clone the server's capabilities are not currently consulted. The client will send shallow requests even if the server does not understand them, and the resulting error may be unhelpful to the user. This change pre-emptively checks so git-clone can exit with a helpful error if necessary.

Signed-off-by: Mike Edgar <adgar@google.com>
---
 builtin/clone.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/builtin/clone.c b/builtin/clone.c
index b878252..b4e9846 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -944,6 +944,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	refs = transport_get_remote_refs(transport);
 
+	if (option_depth && !is_local && !server_supports("shallow"))
+		die(_("Server does not support shallow clients"));
+
 	if (refs) {
 		mapped_refs = wanted_peer_refs(refs, refspec);
 		/*
-- 
2.2.0.rc0.207.ga3a616c
Next: Jeff King
Message 1 of 12 in “clone: check if server supports shallow clones”
  1. clone: check if server supports shallow clonesMike Edgar, Jun 10, 2015
  2. Jeff KingJun 10, 2015
  3. Michael EdgarJun 10, 2015
  4. Jeff KingJun 10, 2015
  5. Duy NguyenJun 11, 2015
  6. Jeff KingJun 11, 2015
  7. Michael EdgarJun 11, 2015
  8. Junio C HamanoJun 11, 2015
  9. fetch-pack: check for shallow if depth givenMike Edgar, Jun 17, 2015
  10. Jeff KingJun 17, 2015
  11. Junio C HamanoJun 17, 2015
  12. Jeff KingJun 17, 2015

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.