[bug] pull --prune could not delete references due to lock file already exists error
- From
ryenus <ryenus@gmail.com>
- Date
- Jun 25, 2025, 12:32 UTC
- Message-ID
- <CAKkAvaw0sZ0sW9o_0NZdnZknS8M34UST3PetaPBQj5wwvJyjBA@mail.gmail.com>
today I tried to prune the remote refs in a local repo, but `git pull --prune` failed with an error saying it could not delete references. I retried several times and it failed consistently, without a single ref pruned.
I found this interesting comment while looking into the code here: https://github.com/git/git/blob/bd99d6e8db5e2c56dd24395e9711ee7ee564bf4f/refs.c#L2863-L2895
Show 5 quoted lines
> /* > * Since we don't check the references' old_oids, the > * individual updates can't fail, so we can pack all of the > * updates into a single transaction. > */
The problem is the assume is wrong, coz things could fail, one such case is to have two refs like below:
1. origin/TOM/b1 2. origin/TOM/b2 3. origin/tom/b2
Notice there's `TOM` vs `tom` in the path. Another factor is that my local file system is case insensitive. As a result the 3rd ref would fail and cause the transaction to be always rolled back.