Re: [PATCH v3 3/3] fast-export, fast-import: implement signed-commits
- From
Elijah Newren <newren@gmail.com>
- Date
- Apr 30, 2021, 19:59 UTC
- Message-ID
- <CABPp-BGrYYO93V0-cNT_OOfeJpk1aHE39Nf1oLBYE-73Ly1QgQ@mail.gmail.com>
- In-Reply-To
- <87a6pfpnvt.wl-lukeshu@lukeshu.com>
On Fri, Apr 30, 2021 at 12:34 PM Luke Shumaker <lukeshu@lukeshu.com> wrote:
Show 20 quoted lines
> > On Tue, 27 Apr 2021 22:02:47 -0600, > Junio C Hamano wrote: > > Better yet, don't butcher the region of memory pointed by the > > "message" variable the caller uses to keep reading from the > > remainder of the commit object buffer with this and memmove() > > below. Perhaps have the caller pass a strbuf to fill in the > > signature found by this helper as another parameter, and then return > > a bool "Yes, I found a sig" as its return value? > > Stupid question: is there a better way to append a region of bytes to > a strbuf than > > strbuf_addf(&buf, "%.*s", (int)(str_end - str_beg), str); > > ? > > It seems weird to me to invoke the printf machinery for something so > simple, but I don't see anything alternatives in strbuf.h. Am I > missing something?
I struggled to find it some time ago as well; I wonder if some reorganization of strbuf.[ch] might make it more clear.
Anyway, strbuf_add() if you have the number of bytes already handy, strbuf_addstr() if you don't have the number of bytes handy but the string is NUL-delimited.