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

Function initialize_attr_index

merge-ort.c:2039–2095  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2037}
2038
2039static void initialize_attr_index(struct merge_options *opt)
2040{
2041 /*
2042 * The renormalize_buffer() functions require attributes, and
2043 * annoyingly those can only be read from the working tree or from
2044 * an index_state. merge-ort doesn't have an index_state, so we
2045 * generate a fake one containing only attribute information.
2046 */
2047 struct merged_info *mi;
2048 struct index_state *attr_index = &opt->priv->attr_index;
2049 struct cache_entry *ce;
2050
2051 attr_index->repo = opt->repo;
2052 attr_index->initialized = 1;
2053
2054 if (!opt->renormalize)
2055 return;
2056
2057 mi = strmap_get(&opt->priv->paths, GITATTRIBUTES_FILE);
2058 if (!mi)
2059 return;
2060
2061 if (mi->clean) {
2062 int len = strlen(GITATTRIBUTES_FILE);
2063 ce = make_empty_cache_entry(attr_index, len);
2064 ce->ce_mode = create_ce_mode(mi->result.mode);
2065 ce->ce_flags = create_ce_flags(0);
2066 ce->ce_namelen = len;
2067 oidcpy(&ce->oid, &mi->result.oid);
2068 memcpy(ce->name, GITATTRIBUTES_FILE, len);
2069 add_index_entry(attr_index, ce,
2070 ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
2071 get_stream_filter(attr_index, GITATTRIBUTES_FILE, &ce->oid);
2072 } else {
2073 int stage, len;
2074 struct conflict_info *ci;
2075
2076 ASSIGN_AND_VERIFY_CI(ci, mi);
2077 for (stage = 0; stage < 3; stage++) {
2078 unsigned stage_mask = (1 << stage);
2079
2080 if (!(ci->filemask & stage_mask))
2081 continue;
2082 len = strlen(GITATTRIBUTES_FILE);
2083 ce = make_empty_cache_entry(attr_index, len);
2084 ce->ce_mode = create_ce_mode(ci->stages[stage].mode);
2085 ce->ce_flags = create_ce_flags(stage);
2086 ce->ce_namelen = len;
2087 oidcpy(&ce->oid, &ci->stages[stage].oid);
2088 memcpy(ce->name, GITATTRIBUTES_FILE, len);
2089 add_index_entry(attr_index, ce,
2090 ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
2091 get_stream_filter(attr_index, GITATTRIBUTES_FILE,
2092 &ce->oid);
2093 }
2094 }
2095}
2096

Callers 2

merge_3wayFunction · 0.85
blob_unchangedFunction · 0.85

Calls 7

strmap_getFunction · 0.85
make_empty_cache_entryFunction · 0.85
create_ce_modeFunction · 0.85
create_ce_flagsFunction · 0.85
oidcpyFunction · 0.85
add_index_entryFunction · 0.85
get_stream_filterFunction · 0.85

Tested by

no test coverage detected