eli-schwartz / aurpublish

PKGBUILD management framework for the Arch User Repository
GNU General Public License v2.0
246 stars 18 forks source link

aurpublish fails with: fatal: cache for already exists! #30

Open aminvakil opened 8 months ago

aminvakil commented 8 months ago

https://github.com/aminvakil/aur/actions/runs/7310240478/job/19918672631

git push using:  aur:zoiper-bin.git master
fatal: cache for d6a34f40a60a78154048a8c37e1d3463f9138ea7 already exists!

Previous to this I've accidentally had a merge commit adding this subtree to master branch, but I've dropped that commit and I still get this, I don't know what to do.

Nothing is changing, just aurpublish zoiper-bin which is a package I'm maintaining.

alerque commented 8 months ago

Can you try cloning this repo to a fresh location and publish from there? That should tell us whether it's something in the repo history (as exists in the remote) or actually a problem with the subtree cache locally.

aminvakil commented 8 months ago

A fresh location (and aurpublish setup afterwards) did not help, it failed with the same error:

git push using:  aur:zoiper-bin.git master
fatal: cache for d6a34f40a60a78154048a8c37e1d3463f9138ea7 already exists!

https://github.com/aminvakil/aur/actions/runs/7313903426/job/19926019741

orhun commented 8 months ago

I remember having the same error in the past after unintentionally rewriting the Git history of the subtree. I think I solved it by setting up aurpublish and adding each package to the subtree again 💀

aminvakil commented 8 months ago

Ah, so I would lost all history in github?

aminvakil commented 8 months ago

I can replicate this locally too, git subtree split -P "zoiper-bin" --rejoin always fails with:

fatal: cache for d6a34f40a60a78154048a8c37e1d3463f9138ea7 already exists!

even after rm -rf .git/subtree-cache/.

alerque commented 8 months ago

I think your options are either to delete and re-add the subtree (min two commits) or backtrack to before whatever commit in your current history rewrote something in the subtree. Probably not far back depending on your workflow. You can use that fresh clone and reset --hard HEAD^ a few times until the problem goes away, then cherry-pick the commits from after the problematic one.

eli-schwartz commented 8 months ago

I bisected this in git itself, to commit https://github.com/git/git/commit/d2f0f819547de35ffc923fc963f806f1656eb2ca

Before this commit, the split verb prints out:

cache for d6a34f40a60a78154048a8c37e1d3463f9138ea7 already exists!
d6a34f40a60a78154048a8c37e1d3463f9138ea7

but succeeds.

It appears that graph traversal which encounters multiple subtree joins is broken, I would report a bug to the git mailing list. Simple reproducer:

git init testme && cd testme
mkdir foo
touch foo/bar
git add foo/bar
git commit -m ...
split_commit=$(git subtree split -P foo --rejoin)
# Added dir 'foo'
echo "${split_commit}"
# 42517e4b9fe310a64be2a777ef08c91bd582b385

git rm -r foo
git commit -m deleted
git subtree add --prefix foo "${split_commit}"
# Added dir 'foo'
git subtree split -P foo --rejoin
# fatal: cache for 42517e4b9fe310a64be2a777ef08c91bd582b385 already exists!
aminvakil commented 8 months ago

@alerque @orhun @eli-schwartz Thanks for taking a look at this, I've reset --hard to before any of this happens and thankfully nothing else has changed in repo since then, and it got fixed too.

And I've kept https://github.com/aminvakil/aur/tree/broken_subtree before doing this, in case anyone wanted to reference to it for any reason (I think Eli's reproducer suffices, but anyway).

I would keep this open until the issue is fixed in git (I couldn't find Eli's mail in https://public-inbox.org/git/, not sure if it was the correct place to look for it though), but please close this in case it isn't necessary.

eli-schwartz commented 8 months ago

I would keep this open until the issue is fixed in git (I couldn't find Eli's mail in https://public-inbox.org/git/, not sure if it was the correct place to look for it though), but please close this in case it isn't necessary.

It is the correct place to look, but when I said "I would report a bug to the git mailing list" that was advice, not "I have reported".

:P

However, I've decided to report it myself anyway: https://public-inbox.org/git/6de00946-9c5a-4854-9e49-069a22f8a782@gmail.com/T/

aminvakil commented 8 months ago

I would keep this open until the issue is fixed in git (I couldn't find Eli's mail in https://public-inbox.org/git/, not sure if it was the correct place to look for it though), but please close this in case it isn't necessary.

It is the correct place to look, but when I said "I would report a bug to the git mailing list" that was advice, not "I have reported".

:P

However, I've decided to report it myself anyway: https://public-inbox.org/git/6de00946-9c5a-4854-9e49-069a22f8a782@gmail.com/T/

Thanks for doing this. I have little knowledge about git subtrees and couldn't report as good enough as you.