| 588 | } |
| 589 | |
| 590 | int read_oneliner(struct strbuf *buf, |
| 591 | const char *path, unsigned flags) |
| 592 | { |
| 593 | int orig_len = buf->len; |
| 594 | |
| 595 | if (strbuf_read_file(buf, path, 0) < 0) { |
| 596 | if ((flags & READ_ONELINER_WARN_MISSING) || |
| 597 | (errno != ENOENT && errno != ENOTDIR)) |
| 598 | warning_errno(_("could not read '%s'"), path); |
| 599 | return 0; |
| 600 | } |
| 601 | |
| 602 | if (buf->len > orig_len && buf->buf[buf->len - 1] == '\n') { |
| 603 | if (--buf->len > orig_len && buf->buf[buf->len - 1] == '\r') |
| 604 | --buf->len; |
| 605 | buf->buf[buf->len] = '\0'; |
| 606 | } |
| 607 | |
| 608 | if ((flags & READ_ONELINER_SKIP_IF_EMPTY) && buf->len == orig_len) |
| 609 | return 0; |
| 610 | |
| 611 | return 1; |
| 612 | } |
| 613 | |
| 614 | static struct tree *empty_tree(struct repository *r) |
| 615 | { |
no test coverage detected