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

[PATCH/RFC] clone: inform the user we are checking out

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
May 7, 2012, 09:09 UTC
Message-ID
<1336381787-6484-1-git-send-email-kusmabite@gmail.com>

When cloning a large repository over a local file-system, git can use hard-links to the old repository files, making the repository-cloning very fast. However, git also perform an implicit checkout of the files, which can be a lengthy operation.

Inform the user about this, and move the logic to notify the user that we are done until we actually are.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---

I just tried to clone a very large (proprietary) repository over a local filesystyem, and the output struck me as confusing:

---8<--- $ git clone some-repo.git some-other-repo Cloning into 'some-other-repo'... <happens instantly> done. <hangs for minutes> $ ---8<---

Now, seems to be because repo gets hard-linked, so the cloning part did not actually take much time. However, we perform a check-out at the end, and this does take time for my large repo. So the behavior probably makes sense from a git-internals point of view.

But from an end-user point of view, it's confusing. I asked git to clone, and it told me it finished, only to hang around for several minutes while, judging by the output, doing nothing.

So, perhaps it could make sense to do something along these lines?
This gives me this output instead:

---8<--- $ git clone some-repo.git some-other-repo Cloning into 'some-repo'... <happens instantly> Checking out HEAD... <hangs for minutes> done. $ ---8<---

...which seems much more informative to me.
 builtin/clone.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/builtin/clone.c b/builtin/clone.c
index bbd5c96..3f863a1 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -368,9 +368,6 @@ static void clone_local(const char *src_repo, const char *dest_repo)
 		strbuf_release(&src);
 		strbuf_release(&dest);
 	}
-
-	if (0 <= option_verbosity)
-		printf(_("done.\n"));
 }
 
 static const char *junk_work_tree;
@@ -544,6 +541,9 @@ static int checkout(void)
 	if (option_no_checkout)
 		return 0;
 
+	if (0 <= option_verbosity)
+		printf(_("Checking out HEAD...\n"));
+
 	head = resolve_refdup("HEAD", sha1, 1, NULL);
 	if (!head) {
 		warning(_("remote HEAD refers to nonexistent ref, "
@@ -870,5 +870,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	strbuf_release(&key);
 	strbuf_release(&value);
 	junk_pid = 0;
+
+	if (is_local && 0 <= option_verbosity)
+		printf(_("done.\n"));
+
 	return err;
 }
-- 
1.7.10.1.457.g8275905
Next: Johannes Sixt
Message 1 of 7 in “clone: inform the user we are checking out”
  1. clone: inform the user we are checking outErik Faye-Lund, May 7, 2012
  2. Johannes SixtMay 7, 2012
  3. Erik Faye-LundMay 7, 2012
  4. Erik Faye-LundMay 7, 2012
  5. Erik Faye-LundMay 7, 2012
  6. Jeff KingMay 7, 2012
  7. Junio C HamanoMay 7, 2012

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.