Skip to content

features/sparse-checkout-2.24.0 #214

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
77844ca
sparse-checkout: create builtin with 'list' subcommand
derrickstolee Oct 21, 2019
7e12ce4
sparse-checkout: create 'init' subcommand
derrickstolee Oct 21, 2019
2e88571
clone: add --sparse mode
derrickstolee Oct 21, 2019
c6b249a
sparse-checkout: 'set' subcommand
derrickstolee Oct 21, 2019
ead918f
sparse-checkout: add '--stdin' option to set subcommand
derrickstolee Oct 21, 2019
043e1a3
sparse-checkout: create 'disable' subcommand
derrickstolee Oct 21, 2019
d97f70b
trace2: add region in clear_ce_flags
jeffhostetler Oct 21, 2019
95a6be7
sparse-checkout: add 'cone' mode
derrickstolee Oct 21, 2019
fa1e8e3
sparse-checkout: use hashmaps for cone patterns
derrickstolee Oct 21, 2019
93f2e4e
sparse-checkout: init and set in cone mode
derrickstolee Oct 21, 2019
b2522a9
unpack-trees: hash less in cone mode
derrickstolee Oct 21, 2019
705f31c
unpack-trees: add progress to clear_ce_flags()
derrickstolee Oct 21, 2019
4326bc1
read-tree: show progress by default
derrickstolee Oct 21, 2019
f9e96bf
sparse-checkout: sanitize for nested folders
derrickstolee Oct 21, 2019
efd9c53
sparse-checkout: update working directory in-process
derrickstolee Oct 21, 2019
a879c5b
sparse-checkout: write using lockfile
derrickstolee Oct 21, 2019
20e7bd3
sparse-checkout: cone mode should not interact with .gitignore
derrickstolee Oct 21, 2019
8c0b356
Merge ds/sparse-cone
derrickstolee Nov 4, 2019
3641e26
fsmonitor: fix watchman integration
Nov 1, 2019
5a5aefd
credential: set trace2_child_class for credential manager children
jeffhostetler Oct 3, 2019
fc9c77f
sub-process: do not borrow cmd pointer from caller
jeffhostetler Sep 18, 2019
3019adb
sub-process: add subprocess_start_argv()
jeffhostetler Sep 18, 2019
15d8415
sha1-file: add function to update existing loose object cache
jeffhostetler Sep 24, 2019
8259260
packfile: add install_packed_git_and_mru()
jeffhostetler Sep 25, 2019
abfc0a4
index-pack: avoid immediate object fetch while parsing packfile
jeffhostetler Sep 24, 2019
706d2ae
gvfs-helper: create tool to fetch objects using the GVFS Protocol
jeffhostetler Aug 13, 2019
73d2d38
gvfs-helper: fix race condition when creating loose object dirs
derrickstolee Oct 4, 2019
7f68d1d
sha1-file: create shared-cache directory if it doesn't exist
jeffhostetler Oct 7, 2019
c478dfb
gvfs-helper-client: rename ghs__ symbols to gh_server__
jeffhostetler Oct 8, 2019
1c31a8c
gvfs-helper-client: rename ghs__chosen_odb to gh_client__chosen_odb f…
jeffhostetler Oct 8, 2019
16e40b3
gvfs-helper-client: rename ghc__ symbols to gh_client__ for clarity
jeffhostetler Oct 8, 2019
617fd05
gvfs-helper: better handling of network errors
jeffhostetler Oct 8, 2019
891a51b
gvfs-helper-client: properly update loose cache with fetched OID
jeffhostetler Oct 8, 2019
df4a8db
gvfs-helper: V2 robust retry and throttling
jeffhostetler Oct 10, 2019
ae0c9cc
gvfs-helper: expose gvfs/objects GET and POST semantics
jeffhostetler Oct 21, 2019
740de11
gvfs-helper: dramatically reduce progress noise
derrickstolee Oct 24, 2019
8cf9286
gvfs-helper-client.h: define struct object_id
derrickstolee Nov 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
/git-gc
/git-get-tar-commit-id
/git-grep
/git-gvfs-helper
/git-hash-object
/git-help
/git-http-backend
Expand Down Expand Up @@ -158,6 +159,7 @@
/git-show-branch
/git-show-index
/git-show-ref
/git-sparse-checkout
/git-stage
/git-stash
/git-status
Expand Down
2 changes: 2 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ include::config/gui.txt[]

include::config/guitool.txt[]

include::config/gvfs.txt[]

include::config/help.txt[]

include::config/http.txt[]
Expand Down
13 changes: 11 additions & 2 deletions Documentation/config/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,18 @@ core.gvfs::
flag just blocks them from occurring at all.
--

core.useGvfsHelper::
TODO

core.sparseCheckout::
Enable "sparse checkout" feature. See section "Sparse checkout" in
linkgit:git-read-tree[1] for more information.
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
for more information.

core.sparseCheckoutCone::
Enables the "cone mode" of the sparse checkout feature. When the
sparse-checkout file contains a limited set of patterns, then this
mode provides significant performance advantages. See
linkgit:git-sparse-checkout[1] for more information.

core.abbrev::
Set the length object names are abbreviated to. If
Expand Down
5 changes: 5 additions & 0 deletions Documentation/config/gvfs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
gvfs.cache-server::
TODO

gvfs.sharedcache::
TODO
8 changes: 7 additions & 1 deletion Documentation/git-clone.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SYNOPSIS
[--dissociate] [--separate-git-dir <git dir>]
[--depth <depth>] [--[no-]single-branch] [--no-tags]
[--recurse-submodules[=<pathspec>]] [--[no-]shallow-submodules]
[--[no-]remote-submodules] [--jobs <n>] [--] <repository>
[--[no-]remote-submodules] [--jobs <n>] [--sparse] [--] <repository>
[<directory>]

DESCRIPTION
Expand Down Expand Up @@ -156,6 +156,12 @@ objects from the source repository into a pack in the cloned repository.
used, neither remote-tracking branches nor the related
configuration variables are created.

--sparse::
Initialize the sparse-checkout file so the working
directory starts with only the files in the root
of the repository. The sparse-checkout file can be
modified to grow the working directory as needed.

--mirror::
Set up a mirror of the source repository. This implies `--bare`.
Compared to `--bare`, `--mirror` not only maps local branches of the
Expand Down
2 changes: 1 addition & 1 deletion Documentation/git-read-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ support.
SEE ALSO
--------
linkgit:git-write-tree[1]; linkgit:git-ls-files[1];
linkgit:gitignore[5]
linkgit:gitignore[5]; linkgit:git-sparse-checkout[1];

GIT
---
Expand Down
153 changes: 153 additions & 0 deletions Documentation/git-sparse-checkout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
git-sparse-checkout(1)
======================

NAME
----
git-sparse-checkout - Initialize and modify the sparse-checkout
configuration, which reduces the checkout to a set of directories
given by a list of prefixes.


SYNOPSIS
--------
[verse]
'git sparse-checkout <subcommand> [options]'


DESCRIPTION
-----------

Initialize and modify the sparse-checkout configuration, which reduces
the checkout to a set of directories given by a list of prefixes.

THIS COMMAND IS EXPERIMENTAL. ITS BEHAVIOR, AND THE BEHAVIOR OF OTHER
COMMANDS IN THE PRESENCE OF SPARSE-CHECKOUTS, WILL LIKELY CHANGE IN
THE FUTURE.


COMMANDS
--------
'list'::
Provide a list of the contents in the sparse-checkout file.

'init'::
Enable the `core.sparseCheckout` setting. If the
sparse-checkout file does not exist, then populate it with
patterns that match every file in the root directory and
no other directories, then will remove all directories tracked
by Git. Add patterns to the sparse-checkout file to
repopulate the working directory.
+
To avoid interfering with other worktrees, it first enables the
`extensions.worktreeConfig` setting and makes sure to set the
`core.sparseCheckout` setting in the worktree-specific config file.

'set'::
Write a set of patterns to the sparse-checkout file, as given as
a list of arguments following the 'set' subcommand. Update the
working directory to match the new patterns. Enable the
core.sparseCheckout config setting if it is not already enabled.

'disable'::
Remove the sparse-checkout file, set `core.sparseCheckout` to
`false`, and restore the working directory to include all files.

SPARSE CHECKOUT
---------------

"Sparse checkout" allows populating the working directory sparsely.
It uses the skip-worktree bit (see linkgit:git-update-index[1]) to tell
Git whether a file in the working directory is worth looking at. If
the skip-worktree bit is set, then the file is ignored in the working
directory. Git will not populate the contents of those files, which
makes a sparse checkout helpful when working in a repository with many
files, but only a few are important to the current user.

The `$GIT_DIR/info/sparse-checkout` file is used to define the
skip-worktree reference bitmap. When Git updates the working
directory, it updates the skip-worktree bits in the index based
on this file. The files matching the patterns in the file will
appear in the working directory, and the rest will not.

To enable the sparse-checkout feature, run `git sparse-checkout init` to
initialize a simple sparse-checkout file and enable the `core.sparseCheckout`
config setting. Then, run `git sparse-checkout set` to modify the patterns in
the sparse-checkout file.

To repopulate the working directory with all files, use the
`git sparse-checkout disable` command.

## FULL PATTERN SET

By default, the sparse-checkout file uses the same syntax as `.gitignore`
files.

While `$GIT_DIR/info/sparse-checkout` is usually used to specify what
files are included, you can also specify what files are _not_ included,
using negative patterns. For example, to remove the file `unwanted`:

----------------
/*
!unwanted
----------------


## CONE PATTERN SET

The full pattern set allows for arbitrary pattern matches and complicated
inclusion/exclusion rules. These can result in O(N*M) pattern matches when
updating the index, where N is the number of patterns and M is the number
of paths in the index. To combat this performance issue, a more restricted
pattern set is allowed when `core.spareCheckoutCone` is enabled.

The accepted patterns in the cone pattern set are:

1. *Recursive:* All paths inside a directory are included.

2. *Parent:* All files immediately inside a directory are included.

In addition to the above two patterns, we also expect that all files in the
root directory are included. If a recursive pattern is added, then all
leading directories are added as parent patterns.

By default, when running `git sparse-checkout init`, the root directory is
added as a parent pattern. At this point, the sparse-checkout file contains
the following patterns:

```
/*
!/*/
```

This says "include everything in root, but nothing two levels below root."
If we then add the folder `A/B/C` as a recursive pattern, the folders `A` and
`A/B` are added as parent patterns. The resulting sparse-checkout file is
now

```
/*
!/*/
/A/
!/A/*/
/A/B/
!/A/B/*/
/A/B/C/
```

Here, order matters, so the negative patterns are overridden by the positive
patterns that appear lower in the file.

If `core.sparseCheckoutCone=true`, then Git will parse the sparse-checkout file
expecting patterns of these types. Git will warn if the patterns do not match.
If the patterns do match the expected format, then Git will use faster hash-
based algorithms to compute inclusion in the sparse-checkout.

SEE ALSO
--------

linkgit:git-read-tree[1]
linkgit:gitignore[5]

GIT
---
Part of the linkgit:git[1] suite
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,7 @@ LIB_OBJS += gpg-interface.o
LIB_OBJS += graph.o
LIB_OBJS += grep.o
LIB_OBJS += gvfs.o
LIB_OBJS += gvfs-helper-client.o
LIB_OBJS += hashmap.o
LIB_OBJS += linear-assignment.o
LIB_OBJS += help.o
Expand Down Expand Up @@ -1133,6 +1134,7 @@ BUILTIN_OBJS += builtin/shortlog.o
BUILTIN_OBJS += builtin/show-branch.o
BUILTIN_OBJS += builtin/show-index.o
BUILTIN_OBJS += builtin/show-ref.o
BUILTIN_OBJS += builtin/sparse-checkout.o
BUILTIN_OBJS += builtin/stash.o
BUILTIN_OBJS += builtin/stripspace.o
BUILTIN_OBJS += builtin/submodule--helper.o
Expand Down Expand Up @@ -1369,6 +1371,8 @@ else
CURL_LIBCURL += $(shell $(CURL_CONFIG) --libs)
endif

PROGRAM_OBJS += gvfs-helper.o

REMOTE_CURL_PRIMARY = git-remote-http$X
REMOTE_CURL_ALIASES = git-remote-https$X git-remote-ftp$X git-remote-ftps$X
REMOTE_CURL_NAMES = $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES)
Expand Down Expand Up @@ -2479,6 +2483,10 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)

git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)

$(LIB_FILE): $(LIB_OBJS)
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^

Expand Down
1 change: 1 addition & 0 deletions builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix);
int cmd_show(int argc, const char **argv, const char *prefix);
int cmd_show_branch(int argc, const char **argv, const char *prefix);
int cmd_show_index(int argc, const char **argv, const char *prefix);
int cmd_sparse_checkout(int argc, const char **argv, const char *prefix);
int cmd_status(int argc, const char **argv, const char *prefix);
int cmd_stash(int argc, const char **argv, const char *prefix);
int cmd_stripspace(int argc, const char **argv, const char *prefix);
Expand Down
27 changes: 27 additions & 0 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static const char *real_git_dir;
static char *option_upload_pack = "git-upload-pack";
static int option_verbosity;
static int option_progress = -1;
static int option_sparse_checkout;
static enum transport_family family;
static struct string_list option_config = STRING_LIST_INIT_NODUP;
static struct string_list option_required_reference = STRING_LIST_INIT_NODUP;
Expand Down Expand Up @@ -146,6 +147,8 @@ static struct option builtin_clone_options[] = {
OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
OPT_BOOL(0, "remote-submodules", &option_remote_submodules,
N_("any cloned submodules will use their remote-tracking branch")),
OPT_BOOL(0, "sparse", &option_sparse_checkout,
N_("initialize sparse-checkout file to include only files at root")),
OPT_END()
};

Expand Down Expand Up @@ -733,6 +736,27 @@ static void update_head(const struct ref *our, const struct ref *remote,
}
}

static int git_sparse_checkout_init(const char *repo)
{
struct argv_array argv = ARGV_ARRAY_INIT;
int result = 0;
argv_array_pushl(&argv, "-C", repo, "sparse-checkout", "init", NULL);

/*
* We must apply the setting in the current process
* for the later checkout to use the sparse-checkout file.
*/
core_apply_sparse_checkout = 1;

if (run_command_v_opt(argv.argv, RUN_GIT_CMD)) {
error(_("failed to initialize sparse-checkout"));
result = 1;
}

argv_array_clear(&argv);
return result;
}

static int checkout(int submodule_progress)
{
struct object_id oid;
Expand Down Expand Up @@ -1107,6 +1131,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (option_required_reference.nr || option_optional_reference.nr)
setup_reference();

if (option_sparse_checkout && git_sparse_checkout_init(repo))
return 1;

remote = remote_get(option_origin);

strbuf_addf(&default_refspec, "+%s*:%s*", src_ref_prefix,
Expand Down
2 changes: 1 addition & 1 deletion builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
if (startup_info->have_repository) {
read_lock();
collision_test_needed =
has_object_file_with_flags(oid, OBJECT_INFO_QUICK);
has_object_file_with_flags(oid, OBJECT_INFO_FOR_PREFETCH);
read_unlock();
}

Expand Down
3 changes: 2 additions & 1 deletion builtin/read-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

git_config(git_read_tree_config, NULL);

Expand All @@ -185,7 +186,7 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)

if (opts.reset || opts.merge || opts.prefix) {
if (read_cache_unmerged() && (opts.prefix || opts.merge))
die("You need to resolve your current index first");
die(_("You need to resolve your current index first"));
stage = opts.merge = 1;
}
resolve_undo_clear();
Expand Down
Loading