]> git.ipfire.org Git - thirdparty/git.git/blobdiff - unpack-trees.c
Merge branch 'ds/sparse-allow-empty-working-tree'
[thirdparty/git.git] / unpack-trees.c
index 9a3ccd9d0837a6c5d8826ac00a251911e95a43c9..1fe3764f2b217263d00332bcca203f0c9ef6ee5f 100644 (file)
@@ -404,6 +404,7 @@ static int check_updates(struct unpack_trees_options *o,
        state.quiet = 1;
        state.refresh_cache = 1;
        state.istate = index;
+       clone_checkout_metadata(&state.meta, &o->meta, NULL);
 
        if (!o->update || o->dry_run) {
                remove_marked_cache_entries(index, 0);
@@ -455,9 +456,8 @@ static int check_updates(struct unpack_trees_options *o,
                                continue;
                        oid_array_append(&to_fetch, &ce->oid);
                }
-               if (to_fetch.nr)
-                       promisor_remote_get_direct(the_repository,
-                                                  to_fetch.oid, to_fetch.nr);
+               promisor_remote_get_direct(the_repository,
+                                          to_fetch.oid, to_fetch.nr);
                oid_array_clear(&to_fetch);
        }
        for (i = 0; i < index->cache_nr; i++) {
@@ -1932,9 +1932,6 @@ static void invalidate_ce_path(const struct cache_entry *ce,
 /*
  * Check that checking out ce->sha1 in subdir ce->name is not
  * going to overwrite any working files.
- *
- * Currently, git does not checkout subprojects during a superproject
- * checkout, so it is not going to overwrite anything.
  */
 static int verify_clean_submodule(const char *old_sha1,
                                  const struct cache_entry *ce,
@@ -2180,7 +2177,7 @@ static int merged_entry(const struct cache_entry *ce,
                }
                invalidate_ce_path(merge, o);
 
-               if (submodule_from_ce(ce)) {
+               if (submodule_from_ce(ce) && file_exists(ce->name)) {
                        int ret = check_submodule_move_head(ce, NULL,
                                                            oid_to_hex(&ce->oid),
                                                            o);
@@ -2209,7 +2206,7 @@ static int merged_entry(const struct cache_entry *ce,
                        invalidate_ce_path(old, o);
                }
 
-               if (submodule_from_ce(ce)) {
+               if (submodule_from_ce(ce) && file_exists(ce->name)) {
                        int ret = check_submodule_move_head(ce, oid_to_hex(&old->oid),
                                                            oid_to_hex(&ce->oid),
                                                            o);