Re: [PATCH 3/3] refs.c: remove lock_fd from struct ref_lock
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- Apr 15, 2015, 08:49 UTC
- Message-ID
- <552E2608.7020104@alum.mit.edu>
- In-Reply-To
- <1429050308-9617-4-git-send-email-sbeller@google.com>
On 04/15/2015 12:25 AM, Stefan Beller wrote:
Show 6 quoted lines
> The 'lock_fd' is the same as 'lk->fd'. No need to store it twice so remove > it. You may argue this introduces more coupling as we need to know more > about the internals of the lock file mechanism, but this will be solved in > a later patch. > > No functional changes intended.
This whole series LGTM; however, I suggest that this patch be split up. See below.
Show 23 quoted lines
> Signed-off-by: Stefan Beller <sbeller@google.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> refs.c | 16 ++++++----------
> 1 file changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/refs.c b/refs.c
> index 14e52ca..4066752 100644
> --- a/refs.c
> +++ b/refs.c
> [...]
> @@ -2335,8 +2333,8 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
> goto error_return;
> }
>
> - lock->lock_fd = hold_lock_file_for_update(lock->lk, ref_file, lflags);
> - if (lock->lock_fd < 0) {
> + if (hold_lock_file_for_update(lock->lk, ref_file, lflags) < 0) {
> + last_errno = errno;
> if (errno == ENOENT && --attempts_remaining > 0)
> /*
> * Maybe somebody just deleted one of the
> [...]Here you add the line "last_errno = errno". It is a good change, but it is not part of removing ref_lock::lock_fd.
I suggest that you move this change to a separate commit. You might also consider moving the new line to the "else" clause, because it's really about preserving errno around the call to error() and preparing for "goto error_return".
With or without this split, this patch is
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Michael
-- Michael Haggerty mhagger@alum.mit.edu