commit - 8b692cd00bf22ee0c1455a6d17590b0e2f207a87
commit + c30018ad059b2c8e989a8c469f19a17ab9e17d86
blob - 162f19c9a7709ee0d04c1f0748dc276fda48d502
blob + b7c702a676bb40a91a470d8fb32d5501e32c18cb
--- lib/reference.c
+++ lib/reference.c
{
const struct got_error *err = NULL;
FILE *f;
- char *line;
- size_t len;
- const char delim[3] = {'\0', '\0', '\0'};
+ char *line = NULL;
+ size_t linesize = 0;
+ ssize_t linelen;
struct got_lockfile *lf = NULL;
if (lock) {
return NULL;
}
- line = fparseln(f, &len, NULL, delim, 0);
- if (line == NULL) {
- err = got_error(GOT_ERR_BAD_REF_DATA);
+ linelen = getline(&line, &linesize, f);
+ if (linelen == -1) {
+ if (feof(f))
+ err = NULL; /* ignore empty files (could be locks) */
+ else
+ err = got_error_from_errno2("getline", abspath);
if (lock)
got_lockfile_unlock(lf);
goto done;
}
+ while (linelen > 0 && line[linelen - 1] == '\n') {
+ line[linelen - 1] = '\0';
+ linelen--;
+ }
err = parse_ref_line(ref, name, line);
if (lock) {