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

Function read_one_dir

dir.c:3774–3824  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3772}
3773
3774static int read_one_dir(struct untracked_cache_dir **untracked_,
3775 struct read_data *rd)
3776{
3777 struct untracked_cache_dir ud, *untracked;
3778 const unsigned char *data = rd->data, *end = rd->end;
3779 const unsigned char *eos;
3780 uint64_t value;
3781 int i;
3782
3783 memset(&ud, 0, sizeof(ud));
3784
3785 value = decode_varint(&data);
3786 if (data > end)
3787 return -1;
3788 ud.recurse = 1;
3789 ud.untracked_alloc = value;
3790 ud.untracked_nr = value;
3791 if (ud.untracked_nr)
3792 ALLOC_ARRAY(ud.untracked, ud.untracked_nr);
3793
3794 ud.dirs_alloc = ud.dirs_nr = decode_varint(&data);
3795 if (data > end)
3796 return -1;
3797 ALLOC_ARRAY(ud.dirs, ud.dirs_nr);
3798
3799 eos = memchr(data, '\0', end - data);
3800 if (!eos || eos == end)
3801 return -1;
3802
3803 *untracked_ = untracked = xmalloc(st_add3(sizeof(*untracked), eos - data, 1));
3804 memcpy(untracked, &ud, sizeof(ud));
3805 memcpy(untracked->name, data, eos - data + 1);
3806 data = eos + 1;
3807
3808 for (i = 0; i < untracked->untracked_nr; i++) {
3809 eos = memchr(data, '\0', end - data);
3810 if (!eos || eos == end)
3811 return -1;
3812 untracked->untracked[i] = xmemdupz(data, eos - data);
3813 data = eos + 1;
3814 }
3815
3816 rd->ucd[rd->index++] = untracked;
3817 rd->data = data;
3818
3819 for (i = 0; i < untracked->dirs_nr; i++) {
3820 if (read_one_dir(untracked->dirs + i, rd) < 0)
3821 return -1;
3822 }
3823 return 0;
3824}
3825
3826static void set_check_only(size_t pos, void *cb)
3827{

Callers 1

read_untracked_extensionFunction · 0.85

Calls 3

xmemdupzFunction · 0.85
decode_varintFunction · 0.70
xmallocFunction · 0.70

Tested by

no test coverage detected