clone: inform the user we are checking out
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.
---
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(-)
builtin/clone.c +7 -3
@@ -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; }
Signature · 1 line
1.7.10.1.457.g8275905
Am 5/7/2012 11:09, schrieb Erik Faye-Lund:
Quoted 1 line
When cloning a large repository over a local file-system
...
Quoted 4 lines
$ git clone some-repo.git some-other-repo Cloning into 'some-other-repo'... <happens instantly> done. <hangs for minutes> $
...
Quoted 3 lines
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.
We have a nice "Checking out files" progress indicator. I wonder why you do not see it.
At any rate, it's better to write "done" only after we're really done.
-- Hannes
Quoted 7 lines · Johannes Sixt
Am 5/7/2012 11:09, schrieb Erik Faye-Lund:
Quoted 1 line
When cloning a large repository over a local file-system
...
Quoted 4 lines
$ git clone some-repo.git some-other-repo Cloning into 'some-other-repo'... <happens instantly> done. <hangs for minutes> $
Quoted 8 lines
...
Quoted 3 lines
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.We have a nice "Checking out files" progress indicator. I wonder why you do not see it.
That's a very good point, I forgot about that one. I'll investigate that part. Just to be clear, I'm seeing this problem on version 1.7.10.1.457.g8275905 (junio's 'master' as of right now, AFAICT) on CentOS. I've built with:NO_OPENSSL = YesPleaseNO_CURL = YesPlease
"git config -l" does not reveal that any progress related config-options are set.
Quoted 1 line
At any rate, it's better to write "done" only after we're really done.
Well, perhaps, but at the same time perhaps not: We only write it for local clones, because the remote-clones are quite chatty to begin with, and the remote-stuff seems to inform about it's actions by printing "<performing task x>...done!". Moving the final "done."-printing to the very end might be a step in making these outputs even less consistent. But it might not be important.
Quoted 24 lines · Erik Faye-Lund
Quoted 7 lines · Johannes Sixt
Am 5/7/2012 11:09, schrieb Erik Faye-Lund:
Quoted 1 line
When cloning a large repository over a local file-system
...
Quoted 4 lines
$ git clone some-repo.git some-other-repo Cloning into 'some-other-repo'... <happens instantly> done. <hangs for minutes> $Quoted 8 lines
...
Quoted 3 lines
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.We have a nice "Checking out files" progress indicator. I wonder why you do not see it.
That's a very good point, I forgot about that one. I'll investigate that part. Just to be clear, I'm seeing this problem on version 1.7.10.1.457.g8275905 (junio's 'master' as of right now, AFAICT) on CentOS. I've built with:
NO_OPENSSL= YesPleaseNO_CURL= YesPlease
Quoted 3 lines
"git config -l" does not reveal that any progress related config-options are set.
It seems progress is only enabled when cloning with the verbose-flag. This is because check_updates in unpack-trees.c only enabled progress if both o->update and o->verbose_update is set, and checkout in builtin/clone.c fills in opts.verbose_update with (option_verbosity > 0).
So that's that mystery. I still think the output without the verbose-flag is confusing as-is.
Quoted 10 lines · Erik Faye-Lund
Quoted 8 lines · Erik Faye-Lund
Quoted 7 lines · Johannes Sixt
Am 5/7/2012 11:09, schrieb Erik Faye-Lund:
Quoted 3 lines
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.We have a nice "Checking out files" progress indicator. I wonder why you do not see it.
Quoted 8 lines
It seems progress is only enabled when cloning with the verbose-flag. This is because
check_updatesinunpack-trees.conly enabled progress if botho->updateando->verbose_updateis set, and checkout inbuiltin/clone.cfills in opts.verbose_update with (option_verbosity> 0).So that's that mystery. I still think the output without the verbose-flag is confusing as-is.
OK, some blaming shows that this changed in 5bd631b3 ("clone: support multiple levels of verbosity"), back in February 2010. Before this patch, one would have to specify the "quiet"-flag to clone to suppress progress-output, after the patch the default is progress being off.
This seems like the right thing to do if we want to resurrect the progress-output's default-on behavior:
---8<---
builtin/clone.c +1 -1
@@ -569,7 +569,7 @@ static int checkout(void) opts.update =1 ; opts.merge =1 ; opts.fn = oneway_merge; - opts.verbose_update = (option_verbosity >0 ); + opts.verbose_update = (option_verbosity >=0 ); opts.src_index = &the_index; opts.dst_index = &the_index;
---8<---
Quoted 4 lines · Erik Faye-Lund
OK, some blaming shows that this changed in
5bd631b3("clone: support multiple levels of verbosity"), back in February 2010. Before this patch, one would have to specify the "quiet"-flag to clone to suppress progress-output, after the patch the default is progress being off.
Yeah, I think this is a bug. We already show progress indicators from the transports without "-v", so there is no reason to require it for the checkout progress meter. And reading fbd631b3, it looks like the change is simply a mistake in the patch.
Quoted 8 lines
This seems like the right thing to do if we want to resurrect the progress-output's default-on behavior:
---8<---builtin/clone.c +0
-0
builtin/clone.c static int checkout(void)
Quoted 9 lines
builtin/clone.c +1
-2@@ -569,7 +569,7 @@ static int checkout(void) opts.update =1 ; opts.merge =1 ; opts.fn = oneway_merge; - opts.verbose_update = (option_verbosity >0 ); + opts.verbose_update = (option_verbosity >=0 ); opts.src_index = &the_index; opts.dst_index = &the_index; ---8<---
Yes, that looks correct to me. Thanks for looking into this.
-Peff
Quoted 13 lines · Erik Faye-Lund
OK, some blaming shows that this changed in
5bd631b3("clone: support multiple levels of verbosity"), back in February 2010. Before this patch, one would have to specify the "quiet"-flag to clone to suppress progress-output, after the patch the default is progress being off.This seems like the right thing to do if we want to resurrect the progress-output's default-on behavior:
---8<---builtin/clone.c +0
-0
builtin/clone.c static int checkout(void)
Quoted 9 lines
builtin/clone.c +1
-2@@ -569,7 +569,7 @@ static int checkout(void) opts.update =1 ; opts.merge =1 ; opts.fn = oneway_merge; - opts.verbose_update = (option_verbosity >0 ); + opts.verbose_update = (option_verbosity >=0 ); opts.src_index = &the_index; opts.dst_index = &the_index; ---8<---
Sounds sensible, as the original said "verbosely update unless we were told to be quiet", so the normal case should be verbose_update which will give progress only if it takes too long.
Care to roll a signed-off patch?