Off the back of https://github.com/wbthomason/packer.nvim/issues/200#issuecomment-777848523 I just discovered and used the commit key which is a really nice feature, my initial attempt involved just adding a specific commit to an already installed plugin which resulted in an invalid commit error. Specifying the full commit not just the first characters resulted in an even more obscure git tree error. Finally deleting the plugin and re-installing it with the key specified did work.
Ideally just adding a commit to an already installed plugin as a key would be enough
PS: apologies think I'm averaging an issue a day at this rate 馃槗
Thanks for the report; sorry for all the bugs 馃槵
I'll admit that much of the git commands used came from reading the source of other plugin managers, and this feature has gone largely unused.
This case is supposed to be handled already; packer should pull missing commits and then check out the right commit.
From what you're describing, it sounds like there's a problem with fetching missing commits.
The issue is when you install normally, it does a shallow clone of depth one (this is desirable), which means the only commit you have is whatever HEAD was when you installed it. Thus, if you add a commit key after the fact, when packer, (or the git cli) attempts to check out that ref, it doesn't exist in your clone and fails.
For example
% git clone --depth 1 [email protected]:kyazdani42/nvim-web-devicons.git
Cloning into 'nvim-web-devicons'...
% git log --oneline
cc77712 (grafted, HEAD -> master, origin/master, origin/HEAD) revert back dynamic hl loading
This is the state of a repo from a normal install
Adding a ref now wont work
% git checkout aaffb87b5a640d15a566d9af9e74baafcf9ec016
fatal: reference is not a tree: aaffb87b5a640d15a566d9af9e74baafcf9ec016
This causes packer to fail installing it.
The fix is to first deepen the clone, e.g.
% git fetch --update-shallow origin aaffb87b5a640d15a566d9af9e74baafcf9ec016
From github.com:kyazdani42/nvim-web-devicons
* branch aaffb87b5a640d15a566d9af9e74baafcf9ec016 -> FETCH_HEAD
And now checking out that ref works
% git checkout aaffb87b5a640d15a566d9af9e74baafcf9ec016
Note: switching to 'aaffb87b5a640d15a566d9af9e74baafcf9ec016'.
see --deepen, --update-shallow and --unshallow options to git fetch to add history to a shallow cloned repo.
Yep! The thing is, packer is already supposed to handle this deepening as needed, so there's some bug in either detecting that we need to fetch additional commits or in performing the actual fetching.
Just wanted to add here whilst it's still fresh in my mind that at leas on my mac trying to remove the commit key so a plugin is no longer pinned to a commit causes packer to hang. In my case I was removing a commit key from gitsigns and :PackerSync seemed to stall till I gave up. I just commented out the plugin removed it and re-installed without the key and that worked fine
i have the same issue, i was wondering why specify the commit doesn't working, now i know the workaround is uninstall the package first, thank you