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

Re: Re [bug] pull --prune could not delete references due to lock file already exists error

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jun 30, 2025, 14:20 UTC
Message-ID
<aGKdICvmKlumU0ru@fruit.crustytoothpaste.net>
In-Reply-To
<CAOLa=ZSA273KGPnwZ2aRBU_ybcCTYogBHvUwpa+5CfDOc2bEWg@mail.gmail.com>
On 2025-06-30 at 13:46:35, Karthik Nayak wrote:
Show 27 quoted lines
> I can see few solutions overall (including the one you suggested).
> 
> One solution is to drop duplicates in case insensitive systems, this is
> the shortest and easiest fix for now.
> 
> Perhaps something like (untested back of the hand code):
> 
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index cc0a3deb61..bc79d74b82 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -1352,10 +1352,16 @@ static int prune_refs(struct display_state
> *display_state,
>  					goto cleanup;
>  			}
>  		} else {
> +			const char *prev;
>  			struct string_list refnames = STRING_LIST_INIT_NODUP;
> 
> -			for (ref = stale_refs; ref; ref = ref->next)
> +			for (ref = stale_refs; ref; ref = ref->next) {
> +				if (ignore_case && prev && !strcasecmp(ref->next, prev))
> +					continue;
> +
>  				string_list_append(&refnames, ref->name);
> +				prev = ref->name;
> +			}

This won't work in the general case, since the two refs that match case insensitively aren't guaranteed to be adjacent. For instance:

    refs/heads/AAAA
    refs/heads/AAAB
    refs/heads/aaaa
    refs/heads/aaab

They'll be in the above order for a bytewise comparison, but the matching entries won't be adjacent in the list.

Another option is for users on case-insensitive systems to use reftable, which won't have the same problems as the file-based backend and will preserve case properly.

-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
Previous: Karthik NayakNext: Junio C Hamano
Message 6 of 14 in “[bug] pull --prune could not delete references due to lock file already exists error”
  1. ryenusJun 25, 2025
  2. Re [bug] pull --prune could not delete references due to lock file already exists errorK Jayatheerth, Jun 25, 2025
  3. brian m. carlsonJun 27, 2025
  4. JAYATHEERTH KJun 30, 2025
  5. Karthik NayakJun 30, 2025
  6. brian m. carlsonJun 30, 2025
  7. Junio C HamanoJun 30, 2025
  8. Patrick SteinhardtJul 1, 2025
  9. Junio C HamanoJul 1, 2025
  10. Patrick SteinhardtJul 2, 2025
  11. Karthik NayakJul 1, 2025
  12. Chris TorekJul 2, 2025
  13. Junio C HamanoJul 2, 2025
  14. JAYATHEERTH KJul 1, 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.