public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Han Young <hanyang.tony@bytedance•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH v2] read-cache: report lock error when refreshing index
Date: Mon, 07 Jul 2025 11:01:12 -0700	[thread overview]
Message-ID: <xmqq8qkz5193.fsf@gitster.g> (raw)
In-Reply-To: <20250703074502.45593-1-hanyang.tony@bytedance.com> (Han Young's message of "Thu, 3 Jul 2025 15:45:02 +0800")

Han Young <hanyang.tony@bytedance•com> writes:

> In the repo_refresh_and_write_index of read-cache.c, we return -1 to
> indicate that writing the index to disk failed.
> However, callers do not use this information. Commands such as stash print
>   "could not write index"
> and then exit, which does not help to discover the exact problem.
>
> We can let repo_hold_locked_index print the error message if the locking
> failed.
>
> Signed-off-by: Han Young <hanyang.tony@bytedance•com>
> ---
> Changes since v1:
> also check the "could not write index" error output
>
>  read-cache.c     |  2 +-
>  t/t3903-stash.sh | 18 ++++++------------
>  2 files changed, 7 insertions(+), 13 deletions(-)
>
> diff --git a/read-cache.c b/read-cache.c
> index c0bb760ad..50e842bfa 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -1456,7 +1456,7 @@ int repo_refresh_and_write_index(struct repository *repo,
>  	struct lock_file lock_file = LOCK_INIT;
>  	int fd, ret = 0;
>  
> -	fd = repo_hold_locked_index(repo, &lock_file, 0);
> +	fd = repo_hold_locked_index(repo, &lock_file, gentle ? 0 : LOCK_REPORT_ON_ERROR);

Let's wrap this line to stay under 80-columns, i.e.

	fd = repo_hold_locked_index(repo, &lock_file,
				    gentle ? 0 : LOCK_REPORT_ON_ERROR);

No need to resend, as I've done so locally while applying.

  reply	other threads:[~2025-07-07 18:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-01 11:57 [PATCH] read-cache: report lock error when refreshing index Han Young
2025-07-01 16:08 ` Justin Tobler
2025-07-01 19:21   ` Junio C Hamano
2025-07-03  7:45 ` [PATCH v2] " Han Young
2025-07-07 18:01   ` Junio C Hamano [this message]
2025-07-08  2:47     ` [External] " Han Young

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=xmqq8qkz5193.fsf@gitster.g \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=hanyang.tony@bytedance$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox