git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] refs: add GIT_TRACE_REFS debugging mechanism

From
Han-Wen Nienhuys <hanwen@google.com>
Date
Sep 9, 2020, 09:43 UTC
Message-ID
<CAFQ2z_OOCvFH-+FNdPWjQ=vGwgeBdVzMjt8avm6AkX=H81kPdQ@mail.gmail.com>
In-Reply-To
<xmqq7dt4x957.fsf@gitster.c.googlers.com>
On Tue, Sep 8, 2020 at 11:15 PM Junio C Hamano <gitster@pobox.com> wrote:
> Cute.  I like it.
thanks :)
> > +     res = malloc(sizeof(struct debug_ref_store));
> > +     be_copy = malloc(sizeof(*be_copy));
>
> Not xmalloc() and friends?
done.
Show 7 quoted lines
>
> > +     *be_copy = refs_be_debug;
> > +     be_copy->name = store->be->name;
>
> I guess we never destroy the ref-store instances so it is OK to
> assume that it would not cause problems later by sharing pieces of
> memory with underlying "real" thing like this.
correct. But changed to xstrdup to avoid confusion.
> > +     char o[200] = "null";
> > +     char n[200] = "null";
>
> I thought we had better constant than 200 (later you use 100 in the
done.
> same patch).  I am not sure how I feel about "null"; all places in
> Git, we tend to use 0{length-of-the-hash} for "no object name on
> this side", I think.

Some functions take NULL as a legitimate parameter, eg. a transaction update with NULL as old OID (don't check old OID) is different from an update with 0{40} as old OID. (ref must not exist yet).

Show 5 quoted lines
> > +     for (int i = 0; i < transaction->nr; i++) {
>
> We still do not allow variable decl inside the set-up part of a
> for(;;) statement, if I recall Documentation/CodingGuidelines
> correctly.
Fixed.
Show 9 quoted lines
> > +static int debug_delete_refs(struct ref_store *ref_store, const char *msg,
> > +                          struct string_list *refnames, unsigned int flags)
> > +{
> > +     struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
> > +     int res =
> > +             drefs->refs->be->delete_refs(drefs->refs, msg, refnames, flags);
> > +     int i = 0;
>
> No need to initialize 'i' here.
Fixed.
-- 
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
Previous: Junio C HamanoNext: Han-Wen Nienhuys via GitGitGadget
Message 7 of 10 in “RFC: refs: add GIT_DEBUG_REFS debugging mechanism”
  1. RFC: refs: add GIT_DEBUG_REFS debugging mechanismHan-Wen Nienhuys via GitGitGadget, Aug 28, 2020
  2. Jonathan TanSep 2, 2020
  3. Jonathan NiederSep 3, 2020
  4. Jeff KingSep 3, 2020
  5. refs: add GIT_TRACE_REFS debugging mechanismHan-Wen Nienhuys via GitGitGadget, Sep 7, 2020
  6. Junio C HamanoSep 8, 2020
  7. Han-Wen NienhuysSep 9, 2020
  8. refs: add GIT_TRACE_REFS debugging mechanismHan-Wen Nienhuys via GitGitGadget, Sep 9, 2020
  9. refs: add GIT_TRACE_REFS debugging mechanismHan-Wen Nienhuys via GitGitGadget, Sep 16, 2020
  10. Fwd: [PATCH] RFC: refs: add GIT_DEBUG_REFS debugging mechanismHan-Wen Nienhuys, Sep 3, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.