summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c63
1 files changed, 55 insertions, 8 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index 9298fe1d9b..f88a69f8e7 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -16,6 +16,8 @@
#include "fsmonitor.h"
#include "object-store.h"
#include "promisor-remote.h"
+#include "entry.h"
+#include "parallel-checkout.h"
/*
* Error messages expected by scripts out of plumbing commands such as
@@ -397,7 +399,7 @@ static int check_updates(struct unpack_trees_options *o,
int errs = 0;
struct progress *progress;
struct checkout state = CHECKOUT_INIT;
- int i;
+ int i, pc_workers, pc_threshold;
trace_performance_enter();
state.force = 1;
@@ -440,7 +442,6 @@ static int check_updates(struct unpack_trees_options *o,
if (should_update_submodules())
load_gitmodules_file(index, &state);
- enable_delayed_checkout(&state);
if (has_promisor_remote()) {
/*
* Prefetch the objects that are to be checked out in the loop
@@ -463,18 +464,31 @@ static int check_updates(struct unpack_trees_options *o,
to_fetch.oid, to_fetch.nr);
oid_array_clear(&to_fetch);
}
+
+ get_parallel_checkout_configs(&pc_workers, &pc_threshold);
+
+ enable_delayed_checkout(&state);
+ if (pc_workers > 1)
+ init_parallel_checkout();
for (i = 0; i < index->cache_nr; i++) {
struct cache_entry *ce = index->cache[i];
if (ce->ce_flags & CE_UPDATE) {
+ size_t last_pc_queue_size = pc_queue_size();
+
if (ce->ce_flags & CE_WT_REMOVE)
BUG("both update and delete flags are set on %s",
ce->name);
- display_progress(progress, ++cnt);
ce->ce_flags &= ~CE_UPDATE;
errs |= checkout_entry(ce, &state, NULL, NULL);
+
+ if (last_pc_queue_size == pc_queue_size())
+ display_progress(progress, ++cnt);
}
}
+ if (pc_workers > 1)
+ errs |= run_parallel_checkout(&state, pc_workers, pc_threshold,
+ progress, &cnt);
stop_progress(&progress);
errs |= finish_delayed_checkout(&state, NULL);
git_attr_set_direction(GIT_ATTR_CHECKIN);
@@ -749,9 +763,13 @@ static int index_pos_by_traverse_info(struct name_entry *names,
strbuf_make_traverse_path(&name, info, names->path, names->pathlen);
strbuf_addch(&name, '/');
pos = index_name_pos(o->src_index, name.buf, name.len);
- if (pos >= 0)
- BUG("This is a directory and should not exist in index");
- pos = -pos - 1;
+ if (pos >= 0) {
+ if (!o->src_index->sparse_index ||
+ !(o->src_index->cache[pos]->ce_flags & CE_SKIP_WORKTREE))
+ BUG("This is a directory and should not exist in index");
+ } else {
+ pos = -pos - 1;
+ }
if (pos >= o->src_index->cache_nr ||
!starts_with(o->src_index->cache[pos]->name, name.buf) ||
(pos > 0 && starts_with(o->src_index->cache[pos-1]->name, name.buf)))
@@ -1020,7 +1038,7 @@ static struct cache_entry *create_ce_entry(const struct traverse_info *info,
size_t len = traverse_path_len(info, tree_entry_len(n));
struct cache_entry *ce =
is_transient ?
- make_empty_transient_cache_entry(len) :
+ make_empty_transient_cache_entry(len, NULL) :
make_empty_cache_entry(istate, len);
ce->ce_mode = create_ce_mode(n->mode);
@@ -1570,6 +1588,7 @@ static int verify_absent(const struct cache_entry *,
*/
int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
{
+ struct repository *repo = the_repository;
int i, ret;
static struct cache_entry *dfc;
struct pattern_list pl;
@@ -1581,6 +1600,12 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
trace_performance_enter();
trace2_region_enter("unpack_trees", "unpack_trees", the_repository);
+ prepare_repo_settings(repo);
+ if (repo->settings.command_requires_full_index) {
+ ensure_full_index(o->src_index);
+ ensure_full_index(o->dst_index);
+ }
+
if (!core_apply_sparse_checkout || !o->update)
o->skip_sparse_checkout = 1;
if (!o->skip_sparse_checkout && !o->pl) {
@@ -2097,7 +2122,7 @@ static int verify_absent_1(const struct cache_entry *ce,
if (o->index_only || o->reset || !o->update)
return 0;
- len = check_leading_path(ce->name, ce_namelen(ce));
+ len = check_leading_path(ce->name, ce_namelen(ce), 0);
if (!len)
return 0;
else if (len > 0) {
@@ -2563,3 +2588,25 @@ int oneway_merge(const struct cache_entry * const *src,
}
return merged_entry(a, old, o);
}
+
+/*
+ * Merge worktree and untracked entries in a stash entry.
+ *
+ * Ignore all index entries. Collapse remaining trees but make sure that they
+ * don't have any conflicting files.
+ */
+int stash_worktree_untracked_merge(const struct cache_entry * const *src,
+ struct unpack_trees_options *o)
+{
+ const struct cache_entry *worktree = src[1];
+ const struct cache_entry *untracked = src[2];
+
+ if (o->merge_size != 2)
+ BUG("invalid merge_size: %d", o->merge_size);
+
+ if (worktree && untracked)
+ return error(_("worktree and untracked commit have duplicate entries: %s"),
+ super_prefixed(worktree->name));
+
+ return merged_entry(worktree ? worktree : untracked, NULL, o);
+}