From: Taylor Blau <me@ttaylorr.com>
To: Birk Tjelmeland <git@birktj.no>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] stash: show error message when lockfile is present
Date: Sun, 7 Nov 2021 23:15:55 -0500 [thread overview]
Message-ID: <YYike53eJEjSX3er@nand.local> (raw)
In-Reply-To: <YYiXw41upJfPS7l0@nand.local>
I forgot to mention in my earlier email, but in this hunk:
> diff --git a/builtin/stash.c b/builtin/stash.c
> index a0ccc8654d..977fcc4e40 100644
> --- a/builtin/stash.c
> +++ b/builtin/stash.c
> @@ -501,7 +501,7 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
> const struct object_id *bases[1];
>
> read_cache_preload(NULL);
> - if (refresh_and_write_cache(REFRESH_QUIET, 0, 0))
> + if (refresh_and_write_cache(REFRESH_QUIET, 0, LOCK_REPORT_ON_ERROR, 0))
> return -1;
>
> if (write_cache_as_tree(&c_tree, 0, NULL))
Not the fault of your patch, but this hunk is unlike the others in that
it only checks the return value of refresh_and_write_cache() is
non-zero, not non-negative.
Looking through refresh_and_write_cache(), we can return a non-zero
value in any one of three cases:
- We could not acquire the index.lock file with
repo_hold_locked_index(), or
- We failed to write the index (indicated by write_locked_index()
failing), or
- refresh_index() returned a non-*zero* value, which happens when it
sets its `has_errors` variable to 1.
So because even non-zero positive return values from this function
indicate an error, this is OK. In other words, the current
implementation of refresh_and_write_cache() (and the functions that it
calls) make it so that it doesn't matter if you check whether the return
value is negative, or non-zero.
But at least for consistency with the other callers (not to mention
saving future readers in this area the same thought process I just wrote
down here) it may be worth changing this to:
if (refresh_and_write_cache(...) < 0)
return -1;
Thanks,
Taylor
next prev parent reply other threads:[~2021-11-08 4:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-07 21:30 [PATCH] stash: show error message when lockfile is present Birk Tjelmeland
2021-11-08 3:21 ` Taylor Blau
2021-11-08 4:15 ` Taylor Blau [this message]
2021-11-08 7:10 ` Junio C Hamano
2021-11-08 17:56 ` Taylor Blau
2021-11-08 19:05 ` Ævar Arnfjörð Bjarmason
2021-11-08 20:05 ` Junio C Hamano
2021-11-08 20:35 ` Birk Tjelmeland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YYike53eJEjSX3er@nand.local \
--to=me@ttaylorr.com \
--cc=git@birktj.no \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.