summaryrefslogtreecommitdiffstats
path: root/builtin/read-tree.c
diff options
context:
space:
mode:
authorVictoria Dye <vdye@github.com>2022-03-01 21:24:28 +0100
committerJunio C Hamano <gitster@pobox.com>2022-03-01 21:36:01 +0100
commit2c66a7c8cefa27ef56efbc76bdfe13696b9dac3a (patch)
tree98b7b1ab12650fda87d8ca3ea89843a45fd516cb /builtin/read-tree.c
parentread-tree: expand sparse checkout test coverage (diff)
downloadgit-2c66a7c8cefa27ef56efbc76bdfe13696b9dac3a.tar.xz
git-2c66a7c8cefa27ef56efbc76bdfe13696b9dac3a.zip
read-tree: integrate with sparse index
Enable use of sparse index in 'git read-tree'. The integration in this patch is limited only to usage of 'read-tree' that does not need additional functional changes for the sparse index to behave as expected (i.e., produce the same user-facing results as a non-sparse index sparse-checkout). To ensure no unexpected behavior occurs, the index is explicitly expanded when: * '--no-sparse-checkout' is specified (because it disables sparse-checkout) * '--prefix' is specified (if the prefix is inside a sparse directory, the prefixed tree cannot be properly traversed) * two or more <tree-ish> arguments are specified ('twoway_merge' and 'threeway_merge' do not yet support merging sparse directories) Signed-off-by: Victoria Dye <vdye@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/read-tree.c')
-rw-r--r--builtin/read-tree.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index c1a401971c..0a52cab775 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -160,8 +160,6 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
argc = parse_options(argc, argv, cmd_prefix, read_tree_options,
read_tree_usage, 0);
- hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
-
prefix_set = opts.prefix ? 1 : 0;
if (1 < opts.merge + opts.reset + prefix_set)
die("Which one? -m, --reset, or --prefix?");
@@ -173,6 +171,11 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
if (opts.reset)
opts.reset = UNPACK_RESET_OVERWRITE_UNTRACKED;
+ prepare_repo_settings(the_repository);
+ the_repository->settings.command_requires_full_index = 0;
+
+ hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
+
/*
* NEEDSWORK
*
@@ -214,6 +217,10 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
if (opts.merge && !opts.index_only)
setup_work_tree();
+ /* TODO: audit sparse index behavior in unpack_trees */
+ if (opts.skip_sparse_checkout || opts.prefix)
+ ensure_full_index(&the_index);
+
if (opts.merge) {
switch (stage - 1) {
case 0:
@@ -223,11 +230,21 @@ int cmd_read_tree(int argc, const char **argv, const char *cmd_prefix)
opts.fn = opts.prefix ? bind_merge : oneway_merge;
break;
case 2:
+ /*
+ * TODO: update twoway_merge to handle edit/edit conflicts in
+ * sparse directories.
+ */
+ ensure_full_index(&the_index);
opts.fn = twoway_merge;
opts.initial_checkout = is_cache_unborn();
break;
case 3:
default:
+ /*
+ * TODO: update threeway_merge to handle edit/edit conflicts in
+ * sparse directories.
+ */
+ ensure_full_index(&the_index);
opts.fn = threeway_merge;
break;
}