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

Function handle_range_1

name-hash.c:393–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391}
392
393static int handle_range_1(
394 struct index_state *istate,
395 int k_start,
396 int k_end,
397 struct dir_entry *parent,
398 struct strbuf *prefix,
399 struct lazy_entry *lazy_entries)
400{
401 int input_prefix_len = prefix->len;
402 int k = k_start;
403
404 while (k < k_end) {
405 struct cache_entry *ce_k = istate->cache[k];
406 const char *name, *slash;
407
408 if (prefix->len && strncmp(ce_k->name, prefix->buf, prefix->len))
409 break;
410
411 name = ce_k->name + prefix->len;
412 slash = strchr(name, '/');
413
414 if (slash) {
415 int len = slash - name;
416 int processed;
417 struct dir_entry *dir_new;
418
419 strbuf_add(prefix, name, len);
420 processed = handle_range_dir(istate, k, k_end, parent, prefix, lazy_entries, &dir_new);
421 if (processed) {
422 k += processed;
423 strbuf_setlen(prefix, input_prefix_len);
424 continue;
425 }
426
427 strbuf_addch(prefix, '/');
428 processed = handle_range_1(istate, k, k_end, dir_new, prefix, lazy_entries);
429 k += processed;
430 strbuf_setlen(prefix, input_prefix_len);
431 continue;
432 }
433
434 /*
435 * It is too expensive to take a lock to insert "ce_k"
436 * into "istate->name_hash" and increment the ref-count
437 * on the "parent" dir. So we defer actually updating
438 * permanent data structures until phase 2 (where we
439 * can change the locking requirements) and simply
440 * accumulate our current results into the lazy_entries
441 * data array).
442 *
443 * We do not need to lock the lazy_entries array because
444 * we have exclusive access to the cells in the range
445 * [k_start,k_end) that this thread was given.
446 */
447 lazy_entries[k].dir = parent;
448 if (parent) {
449 lazy_entries[k].hash_name = memihash_cont(
450 parent->ent.hash,

Callers 2

handle_range_dirFunction · 0.85
lazy_dir_thread_procFunction · 0.85

Calls 6

strbuf_addFunction · 0.85
handle_range_dirFunction · 0.85
strbuf_setlenFunction · 0.85
strbuf_addchFunction · 0.85
memihash_contFunction · 0.85
memihashFunction · 0.85

Tested by

no test coverage detected