From: Junio C Hamano Date: Mon, 25 Jan 2010 01:35:58 +0000 (-0800) Subject: Merge branch 'jc/fix-tree-walk' X-Git-Tag: v1.7.0-rc0~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=026680f881e751311674d97d0f6ed87f06a92bfb;p=git.git Merge branch 'jc/fix-tree-walk' * jc/fix-tree-walk: read-tree --debug-unpack unpack-trees.c: look ahead in the index unpack-trees.c: prepare for looking ahead in the index Aggressive three-way merge: fix D/F case traverse_trees(): handle D/F conflict case sanely more D/F conflict tests tests: move convenience regexp to match object names to test-lib.sh Conflicts: builtin-read-tree.c unpack-trees.c unpack-trees.h --- 026680f881e751311674d97d0f6ed87f06a92bfb diff --cc builtin-read-tree.c index 5fda9905f,0c1f40d10..8bdcab113 --- a/builtin-read-tree.c +++ b/builtin-read-tree.c @@@ -99,8 -126,8 +127,10 @@@ int cmd_read_tree(int argc, const char PARSE_OPT_NONEG, exclude_per_directory_cb }, OPT_SET_INT('i', NULL, &opts.index_only, "don't check the working tree after merging", 1), + OPT_SET_INT(0, "no-sparse-checkout", &opts.skip_sparse_checkout, + "skip applying sparse checkout filter", 1), + OPT_SET_INT(0, "debug-unpack", &opts.debug_unpack, + "debug unpack-trees", 1), OPT_END() }; diff --cc cache.h index 7d5c21e3f,9a9596386..b3370eb41 --- a/cache.h +++ b/cache.h @@@ -177,11 -177,9 +177,13 @@@ struct cache_entry #define CE_HASHED (0x100000) #define CE_UNHASHED (0x200000) +#define CE_CONFLICTED (0x800000) + +/* Only remove in work directory, not index */ +#define CE_WT_REMOVE (0x400000) + #define CE_UNPACKED (0x1000000) + /* * Extended on-disk flags */ diff --cc unpack-trees.c index 0ddbef3e6,10e8871a7..75f54cac9 --- a/unpack-trees.c +++ b/unpack-trees.c @@@ -453,23 -647,12 +720,22 @@@ int unpack_trees(unsigned len, struct t state.quiet = 1; state.refresh_cache = 1; + memset(&el, 0, sizeof(el)); + if (!core_apply_sparse_checkout || !o->update) + o->skip_sparse_checkout = 1; + if (!o->skip_sparse_checkout) { + if (add_excludes_from_file_to_list(git_path("info/sparse-checkout"), "", 0, NULL, &el, 0) < 0) + o->skip_sparse_checkout = 1; + else + o->el = ⪙ + } + memset(&o->result, 0, sizeof(o->result)); o->result.initialized = 1; - if (o->src_index) { - o->result.timestamp.sec = o->src_index->timestamp.sec; - o->result.timestamp.nsec = o->src_index->timestamp.nsec; - } + o->result.timestamp.sec = o->src_index->timestamp.sec; + o->result.timestamp.nsec = o->src_index->timestamp.nsec; o->merge_size = len; + mark_all_ce_unused(o->src_index); if (!dfc) dfc = xcalloc(1, cache_entry_size(0)); @@@ -491,58 -689,28 +772,64 @@@ /* Any left-over entries in the index? */ if (o->merge) { - while (o->pos < o->src_index->cache_nr) { - struct cache_entry *ce = o->src_index->cache[o->pos]; - if (unpack_index_entry(ce, o) < 0) { - ret = unpack_failed(o, NULL); - goto done; - } + while (1) { + struct cache_entry *ce = next_cache_entry(o); + if (!ce) + break; + if (unpack_index_entry(ce, o) < 0) + goto return_failed; } } + mark_all_ce_unused(o->src_index); - if (o->trivial_merges_only && o->nontrivial_merge) - return unpack_failed(o, "Merge requires file-level merging"); + if (o->trivial_merges_only && o->nontrivial_merge) { + ret = unpack_failed(o, "Merge requires file-level merging"); + goto done; + } + + if (!o->skip_sparse_checkout) { + int empty_worktree = 1; + for (i = 0;i < o->result.cache_nr;i++) { + struct cache_entry *ce = o->result.cache[i]; + + if (apply_sparse_checkout(ce, o)) { + ret = -1; + goto done; + } + /* + * Merge strategies may set CE_UPDATE|CE_REMOVE outside checkout + * area as a result of ce_skip_worktree() shortcuts in + * verify_absent() and verify_uptodate(). Clear them. + */ + if (ce_skip_worktree(ce)) + ce->ce_flags &= ~(CE_UPDATE | CE_REMOVE); + else + empty_worktree = 0; + + } + if (o->result.cache_nr && empty_worktree) { + ret = unpack_failed(o, "Sparse checkout leaves no entry on working directory"); + goto done; + } + } o->src_index = NULL; ret = check_updates(o) ? (-2) : 0; if (o->dst_index) *o->dst_index = o->result; + +done: + for (i = 0;i < el.nr;i++) + free(el.excludes[i]); + if (el.excludes) + free(el.excludes); + return ret; + + return_failed: + mark_all_ce_unused(o->src_index); - return unpack_failed(o, NULL); ++ ret = unpack_failed(o, NULL); ++ goto done; } /* Here come the merge functions */ diff --cc unpack-trees.h index 95ff36c82,701dca59a..ef70eab39 --- a/unpack-trees.h +++ b/unpack-trees.h @@@ -31,10 -28,10 +31,11 @@@ struct unpack_trees_options skip_unmerged, initial_checkout, diff_index_cached, + debug_unpack, + skip_sparse_checkout, gently; const char *prefix; - int pos; + int cache_bottom; struct dir_struct *dir; merge_fn_t fn; struct unpack_trees_error_msgs msgs;