Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show progress in 'git read-tree' #200

Conversation

derrickstolee
Copy link
Collaborator

@derrickstolee derrickstolee commented Sep 24, 2019

When updating a sparse-checkout, it can be confusing what is taking so much time. Usually, it is the git read-tree -mu HEAD call.

This PR adds progress to the 'git read-tree' builtin by

  1. Adding progress to clear_ce_flags().
  2. Using progress by default when in a terminal.

Here is an example of output for the Linux kernel repo:

$ git read-tree -mu --verbose HEAD
Updating index flags: 100% (62475/62475), done.
Checking out files: 100% (46804/46804), done.

Resolves #181.

When a large repository has many sparse-checkout patterns, the
process for updating the skip-worktree bits can take long enough
that a user gets confused why nothing is happening. Update the
clear_ce_flags() method to write progress.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
The read-tree builtin has a --verbose option that signals to show
progress and other data while updating the index. Update this to
be on by default when stderr is a terminal window.

This will help tools like 'git sparse-checkout' to automatically
benefit from progress indicators when a user runs these commands.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
@@ -162,6 +162,7 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
opts.head_idx = -1;
opts.src_index = &the_index;
opts.dst_index = &the_index;
opts.verbose_update = isatty(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should opts.verbose_update be false if --quiet is specified?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that quiet means something other than "not verbose". This is non-obvious.

The quiet member in struct unpack_trees_options only toggles the output of error messages. This is different than the verbose_update member which toggles the existing progress indicators during the checkout.

Today, if you say git read-tree --verbose --quiet -mu HEAD, then you will still get progress indicators during the "Checking out files" step.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the details here, I couldn't quite figure out what --quiet was controlling.

unpack-trees.c Show resolved Hide resolved
Copy link

@jeffhostetler jeffhostetler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine as is. However, it would be better if we could use the ce offset trick and give this change a lighter footprint.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
@derrickstolee derrickstolee merged commit 17088e6 into microsoft:features/sparse-checkout-2.23.0 Sep 25, 2019
derrickstolee added a commit to microsoft/scalar that referenced this pull request Sep 26, 2019
See microsoft/git#200 for details. Resolves microsoft/git#181.

This will give users more ideas of how long a command will take when modifying the sparse-checkout definition. In particular, we will notice if clear_ce_flags() is suddenly slow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants