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

Function update_some

builtin/checkout.c:193–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193static int update_some(const struct object_id *oid, struct strbuf *base,
194 const char *pathname, unsigned mode, void *context)
195{
196 int len;
197 struct cache_entry *ce;
198 int pos;
199 int overlay_mode = context ? *((int *)context) : 1;
200
201 if (S_ISDIR(mode))
202 return try_update_sparse_directory(oid, base, pathname,
203 overlay_mode);
204
205 len = base->len + strlen(pathname);
206 ce = make_empty_cache_entry(the_repository->index, len);
207 oidcpy(&ce->oid, oid);
208 memcpy(ce->name, base->buf, base->len);
209 memcpy(ce->name + base->len, pathname, len - base->len);
210 ce->ce_flags = create_ce_flags(0) | CE_UPDATE;
211 ce->ce_namelen = len;
212 ce->ce_mode = create_ce_mode(mode);
213
214 /*
215 * If the entry is the same as the current index, we can leave the old
216 * entry in place. Whether it is UPTODATE or not, checkout_entry will
217 * do the right thing.
218 */
219 pos = index_name_pos_sparse(the_repository->index, ce->name, ce->ce_namelen);
220 if (pos >= 0) {
221 struct cache_entry *old = the_repository->index->cache[pos];
222 if (ce->ce_mode == old->ce_mode &&
223 !ce_intent_to_add(old) &&
224 oideq(&ce->oid, &old->oid)) {
225 old->ce_flags |= CE_UPDATE;
226 discard_cache_entry(ce);
227 return 0;
228 }
229 }
230
231 add_index_entry(the_repository->index, ce,
232 ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
233 return 0;
234}
235
236static int read_tree_some(struct tree *tree, const struct pathspec *pathspec,
237 int overlay_mode)

Callers

nothing calls this directly

Calls 9

make_empty_cache_entryFunction · 0.85
oidcpyFunction · 0.85
create_ce_flagsFunction · 0.85
create_ce_modeFunction · 0.85
index_name_pos_sparseFunction · 0.85
oideqFunction · 0.85
discard_cache_entryFunction · 0.85
add_index_entryFunction · 0.85

Tested by

no test coverage detected