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

Re: [PATCH v2] read-cache: report lock error when refreshing index

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 7, 2025, 18:01 UTC
Message-ID
<xmqq8qkz5193.fsf@gitster.g>
In-Reply-To
<20250703074502.45593-1-hanyang.tony@bytedance.com>
Han Young <hanyang.tony@bytedance.com> writes:
Show 28 quoted lines
> 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.
Previous: Han YoungNext: Han Young
Message 5 of 6 in “read-cache: report lock error when refreshing index”
  1. read-cache: report lock error when refreshing indexHan Young, Jul 1, 2025
  2. Justin ToblerJul 1, 2025
  3. Junio C HamanoJul 1, 2025
  4. read-cache: report lock error when refreshing indexHan Young, Jul 3, 2025
  5. Junio C HamanoJul 7, 2025
  6. Han YoungJul 8, 2025

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.