| 254 | } |
| 255 | |
| 256 | static int open_multi_pack_index_chain(const struct git_hash_algo *hash_algo, |
| 257 | const char *chain_file, int *fd, |
| 258 | struct stat *st) |
| 259 | { |
| 260 | *fd = git_open(chain_file); |
| 261 | if (*fd < 0) |
| 262 | return 0; |
| 263 | if (fstat(*fd, st)) { |
| 264 | close(*fd); |
| 265 | return 0; |
| 266 | } |
| 267 | if (st->st_size < hash_algo->hexsz) { |
| 268 | close(*fd); |
| 269 | if (!st->st_size) { |
| 270 | /* treat empty files the same as missing */ |
| 271 | errno = ENOENT; |
| 272 | } else { |
| 273 | warning(_("multi-pack-index chain file too small")); |
| 274 | errno = EINVAL; |
| 275 | } |
| 276 | return 0; |
| 277 | } |
| 278 | return 1; |
| 279 | } |
| 280 | |
| 281 | static int add_midx_to_chain(struct multi_pack_index *midx, |
| 282 | struct multi_pack_index *midx_chain) |
no test coverage detected