unpack-trees(): "enable" sparse checkout and load $GIT_DIR/info/sparse-checkout
This patch introduces core.sparseCheckout, which will control whether sparse checkout support is enabled in unpack_trees() It also loads sparse-checkout file that will be used in the next patch. I split it out so the next patch will be shorter, easier to read. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
35a5aa79d0
commit
08aefc9e47
@ -439,6 +439,10 @@ On some file system/operating system combinations, this is unreliable.
|
|||||||
Set this config setting to 'rename' there; However, This will remove the
|
Set this config setting to 'rename' there; However, This will remove the
|
||||||
check that makes sure that existing object files will not get overwritten.
|
check that makes sure that existing object files will not get overwritten.
|
||||||
|
|
||||||
|
core.sparseCheckout::
|
||||||
|
Enable "sparse checkout" feature. See section "Sparse checkout" in
|
||||||
|
linkgit:git-read-tree[1] for more information.
|
||||||
|
|
||||||
add.ignore-errors::
|
add.ignore-errors::
|
||||||
Tells 'git-add' to continue adding files when some files cannot be
|
Tells 'git-add' to continue adding files when some files cannot be
|
||||||
added due to indexing errors. Equivalent to the '--ignore-errors'
|
added due to indexing errors. Equivalent to the '--ignore-errors'
|
||||||
|
@ -401,7 +401,9 @@ follows:
|
|||||||
----------------
|
----------------
|
||||||
|
|
||||||
Then you can disable sparse checkout. Sparse checkout support in "git
|
Then you can disable sparse checkout. Sparse checkout support in "git
|
||||||
read-tree" and similar commands is disabled by default.
|
read-tree" and similar commands is disabled by default. You need to
|
||||||
|
turn `core.sparseCheckout` on in order to have sparse checkout
|
||||||
|
support.
|
||||||
|
|
||||||
|
|
||||||
SEE ALSO
|
SEE ALSO
|
||||||
|
1
cache.h
1
cache.h
@ -526,6 +526,7 @@ extern size_t delta_base_cache_limit;
|
|||||||
extern int auto_crlf;
|
extern int auto_crlf;
|
||||||
extern int fsync_object_files;
|
extern int fsync_object_files;
|
||||||
extern int core_preload_index;
|
extern int core_preload_index;
|
||||||
|
extern int core_apply_sparse_checkout;
|
||||||
|
|
||||||
enum safe_crlf {
|
enum safe_crlf {
|
||||||
SAFE_CRLF_FALSE = 0,
|
SAFE_CRLF_FALSE = 0,
|
||||||
|
5
config.c
5
config.c
@ -503,6 +503,11 @@ static int git_default_core_config(const char *var, const char *value)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(var, "core.sparsecheckout")) {
|
||||||
|
core_apply_sparse_checkout = git_config_bool(var, value);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add other config variables here and to Documentation/config.txt. */
|
/* Add other config variables here and to Documentation/config.txt. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ enum push_default_type push_default = PUSH_DEFAULT_MATCHING;
|
|||||||
#endif
|
#endif
|
||||||
enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
|
enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;
|
||||||
int grafts_replace_parents = 1;
|
int grafts_replace_parents = 1;
|
||||||
|
int core_apply_sparse_checkout;
|
||||||
|
|
||||||
/* Parallel index stat data preload? */
|
/* Parallel index stat data preload? */
|
||||||
int core_preload_index = 0;
|
int core_preload_index = 0;
|
||||||
|
@ -378,6 +378,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
static struct cache_entry *dfc;
|
static struct cache_entry *dfc;
|
||||||
|
struct exclude_list el;
|
||||||
|
|
||||||
if (len > MAX_UNPACK_TREES)
|
if (len > MAX_UNPACK_TREES)
|
||||||
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
|
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
|
||||||
@ -387,6 +388,16 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
|||||||
state.quiet = 1;
|
state.quiet = 1;
|
||||||
state.refresh_cache = 1;
|
state.refresh_cache = 1;
|
||||||
|
|
||||||
|
memset(&el, 0, sizeof(el));
|
||||||
|
if (!core_apply_sparse_checkout || !o->update)
|
||||||
|
o->skip_sparse_checkout = 1;
|
||||||
|
if (!o->skip_sparse_checkout) {
|
||||||
|
if (add_excludes_from_file_to_list(git_path("info/sparse-checkout"), "", 0, NULL, &el, 0) < 0)
|
||||||
|
o->skip_sparse_checkout = 1;
|
||||||
|
else
|
||||||
|
o->el = ⪙
|
||||||
|
}
|
||||||
|
|
||||||
memset(&o->result, 0, sizeof(o->result));
|
memset(&o->result, 0, sizeof(o->result));
|
||||||
o->result.initialized = 1;
|
o->result.initialized = 1;
|
||||||
if (o->src_index) {
|
if (o->src_index) {
|
||||||
@ -407,26 +418,39 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
|||||||
info.fn = unpack_callback;
|
info.fn = unpack_callback;
|
||||||
info.data = o;
|
info.data = o;
|
||||||
|
|
||||||
if (traverse_trees(len, t, &info) < 0)
|
if (traverse_trees(len, t, &info) < 0) {
|
||||||
return unpack_failed(o, NULL);
|
ret = unpack_failed(o, NULL);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Any left-over entries in the index? */
|
/* Any left-over entries in the index? */
|
||||||
if (o->merge) {
|
if (o->merge) {
|
||||||
while (o->pos < o->src_index->cache_nr) {
|
while (o->pos < o->src_index->cache_nr) {
|
||||||
struct cache_entry *ce = o->src_index->cache[o->pos];
|
struct cache_entry *ce = o->src_index->cache[o->pos];
|
||||||
if (unpack_index_entry(ce, o) < 0)
|
if (unpack_index_entry(ce, o) < 0) {
|
||||||
return unpack_failed(o, NULL);
|
ret = unpack_failed(o, NULL);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o->trivial_merges_only && o->nontrivial_merge)
|
if (o->trivial_merges_only && o->nontrivial_merge) {
|
||||||
return unpack_failed(o, "Merge requires file-level merging");
|
ret = unpack_failed(o, "Merge requires file-level merging");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
o->src_index = NULL;
|
o->src_index = NULL;
|
||||||
ret = check_updates(o) ? (-2) : 0;
|
ret = check_updates(o) ? (-2) : 0;
|
||||||
if (o->dst_index)
|
if (o->dst_index)
|
||||||
*o->dst_index = o->result;
|
*o->dst_index = o->result;
|
||||||
|
|
||||||
|
done:
|
||||||
|
for (i = 0;i < el.nr;i++)
|
||||||
|
free(el.excludes[i]);
|
||||||
|
if (el.excludes)
|
||||||
|
free(el.excludes);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define MAX_UNPACK_TREES 8
|
#define MAX_UNPACK_TREES 8
|
||||||
|
|
||||||
struct unpack_trees_options;
|
struct unpack_trees_options;
|
||||||
|
struct exclude_list;
|
||||||
|
|
||||||
typedef int (*merge_fn_t)(struct cache_entry **src,
|
typedef int (*merge_fn_t)(struct cache_entry **src,
|
||||||
struct unpack_trees_options *options);
|
struct unpack_trees_options *options);
|
||||||
@ -28,6 +29,7 @@ struct unpack_trees_options {
|
|||||||
skip_unmerged,
|
skip_unmerged,
|
||||||
initial_checkout,
|
initial_checkout,
|
||||||
diff_index_cached,
|
diff_index_cached,
|
||||||
|
skip_sparse_checkout,
|
||||||
gently;
|
gently;
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
int pos;
|
int pos;
|
||||||
@ -44,6 +46,8 @@ struct unpack_trees_options {
|
|||||||
struct index_state *dst_index;
|
struct index_state *dst_index;
|
||||||
struct index_state *src_index;
|
struct index_state *src_index;
|
||||||
struct index_state result;
|
struct index_state result;
|
||||||
|
|
||||||
|
struct exclude_list *el; /* for internal use */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int unpack_trees(unsigned n, struct tree_desc *t,
|
extern int unpack_trees(unsigned n, struct tree_desc *t,
|
||||||
|
Loading…
Reference in New Issue
Block a user