| 614 | } |
| 615 | |
| 616 | int open_commit_graph_chain(const char *chain_file, |
| 617 | int *fd, struct stat *st, |
| 618 | const struct git_hash_algo *hash_algo) |
| 619 | { |
| 620 | *fd = git_open(chain_file); |
| 621 | if (*fd < 0) |
| 622 | return 0; |
| 623 | if (fstat(*fd, st)) { |
| 624 | close(*fd); |
| 625 | return 0; |
| 626 | } |
| 627 | if (st->st_size < hash_algo->hexsz) { |
| 628 | close(*fd); |
| 629 | if (!st->st_size) { |
| 630 | /* treat empty files the same as missing */ |
| 631 | errno = ENOENT; |
| 632 | } else { |
| 633 | warning(_("commit-graph chain file too small")); |
| 634 | errno = EINVAL; |
| 635 | } |
| 636 | return 0; |
| 637 | } |
| 638 | return 1; |
| 639 | } |
| 640 | |
| 641 | struct commit_graph *load_commit_graph_chain_fd_st(struct object_database *odb, |
| 642 | int fd, struct stat *st, |
no test coverage detected