MCPcopy Index your code
hub / github.com/git/git / check_packed_git_idx

Function check_packed_git_idx

packfile.c:160–188  ·  view source on GitHub ↗

* Open and mmap the index file at path, perform a couple of * consistency checks, then record its information to p. Return 0 on * success. */

Source from the content-addressed store, hash-verified

158 * success.
159 */
160static int check_packed_git_idx(const char *path, struct packed_git *p)
161{
162 void *idx_map;
163 size_t idx_size;
164 int fd = git_open(path), ret;
165 struct stat st;
166 const unsigned int hashsz = p->repo->hash_algo->rawsz;
167
168 if (fd < 0)
169 return -1;
170 if (fstat(fd, &st)) {
171 close(fd);
172 return -1;
173 }
174 idx_size = xsize_t(st.st_size);
175 if (idx_size < 4 * 256 + hashsz + hashsz) {
176 close(fd);
177 return error("index file %s is too small", path);
178 }
179 idx_map = xmmap(NULL, idx_size, PROT_READ, MAP_PRIVATE, fd, 0);
180 close(fd);
181
182 ret = load_idx(path, hashsz, idx_map, idx_size, p);
183
184 if (ret)
185 munmap(idx_map, idx_size);
186
187 return ret;
188}
189
190int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
191 size_t idx_size, struct packed_git *p)

Callers 2

open_pack_indexFunction · 0.85
parse_pack_indexFunction · 0.85

Calls 4

xsize_tFunction · 0.85
errorFunction · 0.85
xmmapFunction · 0.85
load_idxFunction · 0.85

Tested by

no test coverage detected