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

Re: [PATCH] Function for updating refs.

From
CRCarlos Rica <jasampler@gmail.com>
Date
Sep 5, 2007, 12:03 UTC
Message-ID
<1b46aba20709050503r6027ada3u79ca8f5cb662775f@mail.gmail.com>
In-Reply-To
<7vy7flk2z5.fsf@gitster.siamese.dyndns.org>
2007/9/5, Junio C Hamano <gitster@pobox.com>:
Show 15 quoted lines
> Carlos Rica <jasampler@gmail.com> writes:
> > -     snprintf(msg, sizeof(msg), "%s: %s", rla, action);
> > -     lock = lock_any_ref_for_update(refname, oldval, 0);
> > -     if (!lock)
> > -             return 1;
> > -     if (write_ref_sha1(lock, sha1, msg) < 0)
> > -             return 1;
> > -     return 0;
> > +     if (snprintf(msg, sizeof(msg), "%s: %s", rla, action) >= sizeof(msg))
> > +             error("reflog message too long: %.*s...", 50, msg);
>
> The original I did was sloppy and did not detect this situation;
> thanks for fixing it.  You do not refuse the primary operation,
> which is to update the ref, so this should be a warning instead
> of an error, I think.

Yes, it is. Also, I tested what would happen when the lock fails. I tried to lock an already locked ref, and it died printing the message die("unable to create '%s.lock': %s", path, strerror(errno)); from lockfile.c. I think this is interesting. There are other failing reasons that could make the update_ref function to print its error, but I haven't tested them.

> > diff --git a/send-pack.c b/send-pack.c
> > ...
> This removal makes "struct ref_lock *lock" (not shown in the
> context) unused.  I will remove the declaration.

Thank you. Also in builtin-update-ref.c the main function could return directly that value returned from the call to update_ref().

Previous: Junio C Hamano
Message 3 of 3 in “Function for updating refs.”
  1. Function for updating refs.Carlos Rica, Sep 5, 2007
  2. Junio C HamanoSep 5, 2007
  3. Carlos RicaSep 5, 2007

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.