MCPcopy Create free account
hub / github.com/git/git / unpack_trees

Function unpack_trees

unpack-trees.c:1883–2121  ·  view source on GitHub ↗

* N-way merge "len" trees. Returns 0 on success, -1 on failure to manipulate the * resulting index, -2 on failure to reflect the changes to the work tree. * * CE_ADDED, CE_UNPACKED and CE_NEW_SKIP_WORKTREE are used internally */

Source from the content-addressed store, hash-verified

1881 * CE_ADDED, CE_UNPACKED and CE_NEW_SKIP_WORKTREE are used internally
1882 */
1883int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options *o)
1884{
1885 struct repository *repo = o->src_index->repo;
1886 int i, ret;
1887 static struct cache_entry *dfc;
1888 struct pattern_list pl;
1889 int free_pattern_list = 0;
1890 struct dir_struct dir = DIR_INIT;
1891 struct repo_config_values *cfg = repo_config_values(the_repository);
1892
1893 if (o->reset == UNPACK_RESET_INVALID)
1894 BUG("o->reset had a value of 1; should be UNPACK_TREES_*_UNTRACKED");
1895
1896 if (len > MAX_UNPACK_TREES)
1897 die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
1898 if (o->internal.dir)
1899 BUG("o->internal.dir is for internal use only");
1900 if (o->internal.pl)
1901 BUG("o->internal.pl is for internal use only");
1902 if (o->df_conflict_entry)
1903 BUG("o->df_conflict_entry is an output only field");
1904
1905 trace_performance_enter();
1906 trace2_region_enter("unpack_trees", "unpack_trees", repo);
1907
1908 prepare_repo_settings(repo);
1909 if (repo->settings.command_requires_full_index) {
1910 ensure_full_index(o->src_index);
1911 if (o->dst_index)
1912 ensure_full_index(o->dst_index);
1913 }
1914
1915 if (o->reset == UNPACK_RESET_OVERWRITE_UNTRACKED &&
1916 o->preserve_ignored)
1917 BUG("UNPACK_RESET_OVERWRITE_UNTRACKED incompatible with preserved ignored files");
1918
1919 if (!o->preserve_ignored) {
1920 o->internal.dir = &dir;
1921 o->internal.dir->flags |= DIR_SHOW_IGNORED;
1922 setup_standard_excludes(o->internal.dir);
1923 }
1924
1925 if (o->prefix)
1926 update_sparsity_for_prefix(o->prefix, o->src_index);
1927
1928 if (!cfg->apply_sparse_checkout || !o->update)
1929 o->skip_sparse_checkout = 1;
1930 if (!o->skip_sparse_checkout) {
1931 memset(&pl, 0, sizeof(pl));
1932 free_pattern_list = 1;
1933 populate_from_existing_patterns(o, &pl);
1934 }
1935
1936 index_state_init(&o->internal.result, o->src_index->repo);
1937 o->internal.result.initialized = 1;
1938 o->internal.result.timestamp.sec = o->src_index->timestamp.sec;
1939 o->internal.result.timestamp.nsec = o->src_index->timestamp.nsec;
1940 o->internal.result.version = o->src_index->version;

Callers 15

checkoutFunction · 0.85
parse_treeish_argFunction · 0.85
reset_headFunction · 0.85
checkout_fast_forwardFunction · 0.85
do_resetFunction · 0.85
diff_cacheFunction · 0.85
fast_forward_toFunction · 0.85
merge_treeFunction · 0.85
reset_treeFunction · 0.85
create_index_from_treeFunction · 0.85
diff_include_untrackedFunction · 0.85
reset_indexFunction · 0.85

Calls 15

trace_performance_enterFunction · 0.85
prepare_repo_settingsFunction · 0.85
ensure_full_indexFunction · 0.85
setup_standard_excludesFunction · 0.85
index_state_initFunction · 0.85
init_split_indexFunction · 0.85
oidcpyFunction · 0.85
mark_all_ce_unusedFunction · 0.85
xstrdup_or_nullFunction · 0.85
is_sparse_index_allowedFunction · 0.85

Tested by

no test coverage detected