]> git.ipfire.org Git - thirdparty/git.git/blobdiff - unpack-trees.c
Merge branch 'en/ort-perf-batch-9'
[thirdparty/git.git] / unpack-trees.c
index f5f668f532d8d574735da064f4dfb5feb8c0cd95..8a1afbc1e493c2fe1aecb6836246d7560d72b9aa 100644 (file)
@@ -16,6 +16,7 @@
 #include "fsmonitor.h"
 #include "object-store.h"
 #include "promisor-remote.h"
+#include "entry.h"
 
 /*
  * Error messages expected by scripts out of plumbing commands such as
@@ -417,6 +418,9 @@ static int check_updates(struct unpack_trees_options *o,
 
        progress = get_progress(o, index);
 
+       /* Start with clean cache to avoid using any possibly outdated info. */
+       invalidate_lstat_cache();
+
        git_attr_set_direction(GIT_ATTR_CHECKOUT);
 
        if (should_update_submodules())
@@ -1609,8 +1613,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
        o->merge_size = len;
        mark_all_ce_unused(o->src_index);
 
-       if (o->src_index->fsmonitor_last_update)
-               o->result.fsmonitor_last_update = o->src_index->fsmonitor_last_update;
+       o->result.fsmonitor_last_update =
+               xstrdup_or_null(o->src_index->fsmonitor_last_update);
 
        /*
         * Sparse checkout loop #1: set NEW_SKIP_WORKTREE on existing entries
@@ -2094,7 +2098,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) {
@@ -2560,3 +2564,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);
+}