]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ds/sparse-allow-empty-working-tree'
authorJunio C Hamano <gitster@pobox.com>
Fri, 8 May 2020 21:25:06 +0000 (14:25 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 May 2020 21:25:06 +0000 (14:25 -0700)
The sparse-checkout patterns have been forbidden from excluding all
paths, leaving an empty working tree, for a long time.  This
limitation has been lifted.

* ds/sparse-allow-empty-working-tree:
  sparse-checkout: stop blocking empty workdirs

1  2 
unpack-trees.c

diff --combined unpack-trees.c
index 6bbf58d28eaefb5428f0198e8da897f08bcec94c,9a3ccd9d0837a6c5d8826ac00a251911e95a43c9..1fe3764f2b217263d00332bcca203f0c9ef6ee5f
@@@ -404,7 -404,6 +404,7 @@@ static int check_updates(struct unpack_
        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);
                                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++) {
@@@ -1677,8 -1677,6 +1677,6 @@@ int unpack_trees(unsigned len, struct t
        }
  
        if (!o->skip_sparse_checkout) {
-               int empty_worktree = 1;
                /*
                 * Sparse checkout loop #2: set NEW_SKIP_WORKTREE on entries not in loop #1
                 * If they will have NEW_SKIP_WORKTREE, also set CE_SKIP_WORKTREE
  
                        if (apply_sparse_checkout(&o->result, ce, o))
                                ret = 1;
-                       if (!ce_skip_worktree(ce))
-                               empty_worktree = 0;
-               }
-               /*
-                * Sparse checkout is meant to narrow down checkout area
-                * but it does not make sense to narrow down to empty working
-                * tree. This is usually a mistake in sparse checkout rules.
-                * Do not allow users to do that.
-                */
-               if (o->result.cache_nr && empty_worktree) {
-                       ret = unpack_failed(o, "Sparse checkout leaves no entry on working directory");
-                       goto done;
                }
                if (ret == 1) {
                        /*
@@@ -1779,7 -1764,7 +1764,7 @@@ enum update_sparsity_result update_spar
  {
        enum update_sparsity_result ret = UPDATE_SPARSITY_SUCCESS;
        struct pattern_list pl;
-       int i, empty_worktree;
+       int i;
        unsigned old_show_all_errors;
        int free_pattern_list = 0;
  
  
        /* Then loop over entries and update/remove as needed */
        ret = UPDATE_SPARSITY_SUCCESS;
-       empty_worktree = 1;
        for (i = 0; i < o->src_index->cache_nr; i++) {
                struct cache_entry *ce = o->src_index->cache[i];
  
  
                if (apply_sparse_checkout(o->src_index, ce, o))
                        ret = UPDATE_SPARSITY_WARNINGS;
-               if (!ce_skip_worktree(ce))
-                       empty_worktree = 0;
-       }
-       /*
-        * Sparse checkout is meant to narrow down checkout area
-        * but it does not make sense to narrow down to empty working
-        * tree. This is usually a mistake in sparse checkout rules.
-        * Do not allow users to do that.
-        */
-       if (o->src_index->cache_nr && empty_worktree) {
-               unpack_failed(o, "Sparse checkout leaves no entry on working directory");
-               ret = UPDATE_SPARSITY_INDEX_UPDATE_FAILURES;
-               goto done;
        }
  
  skip_sparse_checkout:
        if (check_updates(o, o->src_index))
                ret = UPDATE_SPARSITY_WORKTREE_UPDATE_FAILURES;
  
- done:
        display_warning_msgs(o);
        o->show_all_errors = old_show_all_errors;
        if (free_pattern_list)
@@@ -1964,6 -1932,9 +1932,6 @@@ static void invalidate_ce_path(const st
  /*
   * 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,
@@@ -2209,7 -2180,7 +2177,7 @@@ static int merged_entry(const struct ca
                }
                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);
                        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);