Re: [PATCH] Function for updating refs.
- From
- Carlos 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().