On Tue, Sep 10, 2024 at 03:19:49PM -0700, karthik nayak wrote: [snip] > > + if (referent->buf[referent->len - 1] != '\n') { > > + ret = fsck_report_ref(o, report, > > + FSCK_MSG_REF_MISSING_NEWLINE, > > + "missing newline"); > > + len++; > > + } > > + > > + strbuf_rtrim(referent); > > + if (check_refname_format(referent->buf, 0)) { > > + ret = fsck_report_ref(o, report, > > + FSCK_MSG_BAD_SYMREF_TARGET, > > + "points to refname with invalid format"); > > + goto out; > > + } > > + > > + if (len != referent->len) { > > Would this work with a symref containing: > > ref: refs/heads/feature\ngarbage\n > > Since we check last character and rtrim, wouldn't this bypass our > checks? Isn't it better to find the first `\n` and check if the index < > referent->len? > We will check the above example by "check_refname_format". It will report the following message: error: ... : badSymrefTarget: points to refname with invalid format