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

Function for_each_root_ref

refs/files-backend.c:360–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

358}
359
360static int for_each_root_ref(struct files_ref_store *refs,
361 int (*cb)(const char *refname, void *cb_data),
362 void *cb_data)
363{
364 struct strbuf path = STRBUF_INIT, refname = STRBUF_INIT;
365 struct dirent *de;
366 int ret;
367 DIR *d;
368
369 files_ref_path(refs, &path, "");
370
371 d = opendir(path.buf);
372 if (!d) {
373 strbuf_release(&path);
374 return -1;
375 }
376
377 while ((de = readdir(d)) != NULL) {
378 unsigned char dtype;
379
380 if (de->d_name[0] == '.')
381 continue;
382 if (ends_with(de->d_name, ".lock"))
383 continue;
384
385 strbuf_reset(&refname);
386 strbuf_addstr(&refname, de->d_name);
387
388 dtype = get_dtype(de, &path, 1);
389 if (dtype == DT_REG && is_root_ref(de->d_name)) {
390 ret = cb(refname.buf, cb_data);
391 if (ret)
392 goto done;
393 }
394 }
395
396 ret = 0;
397
398done:
399 strbuf_release(&refname);
400 strbuf_release(&path);
401 closedir(d);
402 return ret;
403}
404
405struct fill_root_ref_data {
406 struct files_ref_store *refs;

Callers 3

add_root_refsFunction · 0.85
files_fsckFunction · 0.85

Calls 9

files_ref_pathFunction · 0.85
opendirFunction · 0.85
strbuf_releaseFunction · 0.85
readdirFunction · 0.85
ends_withFunction · 0.85
strbuf_addstrFunction · 0.85
get_dtypeFunction · 0.85
is_root_refFunction · 0.85
closedirFunction · 0.85

Tested by

no test coverage detected