Re: [PATCH v2 5/5] refs/debug: trim trailing LF from reflog message
- From
Han-Wen Nienhuys <hanwen@google.com>
- Date
- Nov 29, 2021, 18:29 UTC
- Message-ID
- <CAFQ2z_N20ESyzkPLdGbS9q8HEHGB7_gmaX8FUBR=jGqXLGcL1Q@mail.gmail.com>
- In-Reply-To
- <xmqqilwf72nf.fsf@gitster.g>
On Fri, Nov 26, 2021 at 9:16 AM Junio C Hamano <gitster@pobox.com> wrote:
> > The API promises to have only LF, not CRLF, at the end, so > strbuf_trim_trailing_newline() is a bit overkill (and if payload > happened to end with CR, we would lose it).
it would be best if there was a way to escape characters (ie. "\n" => "\\n"). Do we have a function for that?
Show 12 quoted lines
> > + trace_printf_key(&trace_refs, > > + "reflog_ent %s (ret %d): %s -> %s, %s %ld \"%s\"\n", > > + dbg->refname, ret, o, n, committer, > > + (long int)timestamp, trimmed.buf); > > + strbuf_release(&trimmed); > > return ret; > > } > > Can we use counted bytes in trace_printf()? If we can, it would be > simpler to just scan "msg" for LF and then show only the span > between the beginning of the string and the found LF using "%.*s", > perhaps like this?
I beg to differ - despite this being fewer lines of code, I think pointer arithmetic is best avoided if possible.
-- Han-Wen Nienhuys - Google Munich I work 80%. Don't expect answers from me on Fridays. -- Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Paul Manicle, Halimah DeLaine Prado