git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org, Joe Drew <joe.drew@indexexchange.com>,
	peff@peff.net, gitster@pobox.com
Subject: Re: [PATCH v2 4/4] refs/files: handle D/F conflicts during locking
Date: Tue, 9 Sep 2025 09:10:06 +0200	[thread overview]
Message-ID: <aL_SznrF61hbUMBo@pks.im> (raw)
In-Reply-To: <20250908-587-git-fetch-1-fails-fetches-on-case-insensitive-repositories-v2-4-b2eb2459befb@gmail.com>

On Mon, Sep 08, 2025 at 02:37:38PM +0200, Karthik Nayak wrote:
> The previous commit, added the necessary validation and checks for F/D

s/commit,/commit/

> diff --git a/refs.c b/refs.c
> index 4c1c339ed9..ec4f0e9502 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -1232,6 +1232,12 @@ int ref_transaction_maybe_set_rejected(struct ref_transaction *transaction,
>  	if (err == REF_TRANSACTION_ERROR_GENERIC)
>  		return 0;
>  
> +	/*
> +	 * Remove this refname from the list of refnames used for validation
> +	 */

Nit: it's obvious that we remove the refname from that list, so the
comment is not helping much. It's much more important to explain _why_
we do that though to give readers the necessary context.

> +	string_list_remove(&transaction->refnames,
> +			   transaction->updates[update_idx]->refname, 0);
> +
>  	transaction->updates[update_idx]->rejection_err = err;
>  	ALLOC_GROW(transaction->rejections->update_indices,
>  		   transaction->rejections->nr + 1,
> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index 85f2e14e93..ceeec272ff 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> @@ -852,6 +852,7 @@ static enum ref_transaction_error lock_raw_ref(struct files_ref_store *refs,
>  				goto error_return;
>  			} else if (remove_dir_recursively(&ref_file,
>  							  REMOVE_DIR_EMPTY_ONLY)) {
> +				ret = REF_TRANSACTION_ERROR_NAME_CONFLICT;
>  				if (refs_verify_refname_available(
>  						    &refs->base, refname,
>  						    extras, NULL, 0, err)) {
> @@ -859,7 +860,6 @@ static enum ref_transaction_error lock_raw_ref(struct files_ref_store *refs,
>  					 * The error message set by
>  					 * verify_refname_available() is OK.
>  					 */
> -					ret = REF_TRANSACTION_ERROR_NAME_CONFLICT;
>  					goto error_return;
>  				} else {
>  					/*

Hm, interesting. Previously we'd have returned a generic error in the
`else` branch, which reads like this:

	} else {
		/*
		 * We can't delete the directory,
		 * but we also don't know of any
		 * references that it should
		 * contain.
		 */
		strbuf_addf(err, "there is a non-empty directory '%s' "
			    "blocking reference '%s'",
			    ref_file.buf, refname);
		goto error_return;
	}

So that directory contains something, even though we've previously
verified that it shouldn't, if I understand correctly. The test case you
add does seem to indicate that there are valid cases though where this
can happen on a case insensitive filesystem?

If so, the comment definitely needs to be updated to explain this
additional error case.

One more question is whether it's the correct thing to unconditionally
return REF_TRANSACTION_ERROR_NAME_CONFLICT in that case now. Could it be
that the directory exists but contains some garbage?

Patrick

  reply	other threads:[~2025-09-09  7:10 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02  8:34 [PATCH 0/2] refs/files: fix issues with git-fetch on case-insensitive FS Karthik Nayak
2025-09-02  8:34 ` [PATCH 1/2] refs/files: use correct error type when locking fails Karthik Nayak
2025-09-02 21:22   ` Chris Torek
2025-09-04 20:24     ` Karthik Nayak
2025-09-03  7:40   ` Patrick Steinhardt
2025-09-03 10:38     ` Karthik Nayak
2025-09-03 11:48       ` Patrick Steinhardt
2025-09-03 16:53   ` Junio C Hamano
2025-09-02  8:34 ` [PATCH 2/2] refs/files: handle F/D conflicts in case-insensitive FS Karthik Nayak
2025-09-03  7:40   ` Patrick Steinhardt
2025-09-08  7:27     ` Karthik Nayak
2025-09-03 18:16   ` Junio C Hamano
2025-09-04 22:43     ` Junio C Hamano
2025-09-08  9:27     ` Karthik Nayak
2025-09-08  9:29       ` Karthik Nayak
2025-09-08 12:37 ` [PATCH v2 0/4] refs/files: fix issues with git-fetch on " Karthik Nayak
2025-09-08 12:37   ` [PATCH v2 1/4] refs/files: catch conflicts on case-insensitive file-systems Karthik Nayak
2025-09-09  7:09     ` Patrick Steinhardt
2025-09-11  9:35       ` Karthik Nayak
2025-09-08 12:37   ` [PATCH v2 2/4] refs/files: use correct error type when lock exists Karthik Nayak
2025-09-09  7:10     ` Patrick Steinhardt
2025-09-11 10:14       ` Karthik Nayak
2025-09-08 12:37   ` [PATCH v2 3/4] refs/files: handle F/D conflicts in case-insensitive FS Karthik Nayak
2025-09-08 12:37   ` [PATCH v2 4/4] refs/files: handle D/F conflicts during locking Karthik Nayak
2025-09-09  7:10     ` Patrick Steinhardt [this message]
2025-09-12 11:53       ` Karthik Nayak
2025-09-13 20:54 ` [PATCH v3 0/4] refs/files: fix issues with git-fetch on case-insensitive FS Karthik Nayak
2025-09-13 20:54   ` [PATCH v3 1/4] refs/files: catch conflicts on case-insensitive file-systems Karthik Nayak
2025-09-16 21:13     ` Justin Tobler
2025-09-17  7:33       ` Karthik Nayak
2025-09-17 15:30         ` Karthik Nayak
2025-09-17 15:34         ` Justin Tobler
2025-09-13 20:54   ` [PATCH v3 2/4] refs/files: use correct error type when lock exists Karthik Nayak
2025-09-16  7:51     ` Patrick Steinhardt
2025-09-17  7:37       ` Karthik Nayak
2025-09-16 21:31     ` Justin Tobler
2025-09-17  7:39       ` Karthik Nayak
2025-09-13 20:54   ` [PATCH v3 3/4] refs/files: handle F/D conflicts in case-insensitive FS Karthik Nayak
2025-09-16 21:52     ` Justin Tobler
2025-09-17  7:42       ` Karthik Nayak
2025-09-13 20:54   ` [PATCH v3 4/4] refs/files: handle D/F conflicts during locking Karthik Nayak
2025-09-16 21:53   ` [PATCH v3 0/4] refs/files: fix issues with git-fetch on case-insensitive FS Junio C Hamano
2025-09-17  7:45     ` Karthik Nayak
2025-09-17 14:27       ` Toon Claes
2025-09-17 15:24         ` Karthik Nayak
2025-09-17 17:04           ` Junio C Hamano
2025-09-17 20:40             ` Karthik Nayak
2025-09-17 14:34       ` Junio C Hamano
2025-09-17 15:25         ` Karthik Nayak
2025-09-17 15:25 ` [PATCH v4 " Karthik Nayak
2025-09-17 15:25   ` [PATCH v4 1/4] refs/files: catch conflicts on case-insensitive file-systems Karthik Nayak
2025-09-17 15:25   ` [PATCH v4 2/4] refs/files: use correct error type when lock exists Karthik Nayak
2025-09-17 15:25   ` [PATCH v4 3/4] refs/files: handle F/D conflicts in case-insensitive FS Karthik Nayak
2025-09-17 15:25   ` [PATCH v4 4/4] refs/files: handle D/F conflicts during locking Karthik Nayak
2025-09-17 15:43   ` [PATCH v4 0/4] refs/files: fix issues with git-fetch on case-insensitive FS Justin Tobler
2025-09-17 18:43     ` Toon Claes
2025-09-17 19:55       ` Junio C Hamano
2025-09-17 16:20   ` Junio C Hamano

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=aL_SznrF61hbUMBo@pks.im \
    --to=ps@pks.im \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=joe.drew@indexexchange.com \
    --cc=karthik.188@gmail.com \
    --cc=peff@peff.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).