Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone branch pointed by origin/HEAD instead of 'master' by default #288

Closed
ABorgna opened this issue Sep 20, 2015 · 9 comments
Closed

Clone branch pointed by origin/HEAD instead of 'master' by default #288

ABorgna opened this issue Sep 20, 2015 · 9 comments
Labels

Comments

@ABorgna
Copy link

ABorgna commented Sep 20, 2015

Installing a plugin from github without specifying a branch makes vim-plug try to clone the 'master' branch.
But the repository's default branch can be changed, and the installation fails if 'master' doesn't exist.

Steps to reproduce
  • Add a plugin without a master branch in it's repo to .vimrc.
    Plug 'rdnetto/YCM-Generator'
  • Install it with :PlugInstall.
Output
- Finishing ... Done!
x YCM-Generator:
    error: pathspec 'master' did not match any file(s) known to git.

Explicitly setting the branch option in the plugin line solves the issue, but I think we should use the default branch (which is pointed by the origin's HEAD) if none specified.

@starcraftman
Copy link
Contributor

@ABorgna Isn't that a catch 22 though? We are - during PlugInstall - directly cloning the exact branch requested (master by default) at --depth 1 to reduce bandwidth/storage. How do we know the origin's HEAD ref before cloning? I know you can run git symbolic-ref HEAD post clone.

IMO rdnetto should just have a master branch, like literally every other plugin I've ever installed or seen. Seems silly breaking such a convention for no strong reason I can see. I'd go make a ticket on his plugin regarding that.

@ABorgna
Copy link
Author

ABorgna commented Sep 20, 2015

I agree this is not a common issue, but git clone used without specifying a branch clones the default.
So maybe conditionally adding the -b option iff a branch or tag was explicitly set would fix it.

@starcraftman
Copy link
Contributor

@ABorgna That is true, I think the reason we use the -b option is to prevent it cloning all other branch information into .git (i.e. just fetches the requested one). @junegunn would have to confirm, as I've forgotten if that was the case.

@ABorgna
Copy link
Author

ABorgna commented Sep 21, 2015

-b only sets the branch the local HEAD points to after the clone.
clone_opt has --no-single-branch, so every branch is being fetched (here's @junegunn comment about it).

@junegunn
Copy link
Owner

This was discussed before (#257 (comment)), and I still think it's better to be explicit. Without explicit branch specification, vim-plug has no way to verify if the local clone is in valid state and I believe it's simply better to know in the first place that you're using a non-master branch considering that the author of the plugin can change the default branch at any time.

Most importantly, I've never had to use a plugin that does not use master branch and I don't want to complicate things (code-wise) for such exceptional cases. I'm going to close the issue as wontfix.

@rdnetto
Copy link

rdnetto commented Oct 28, 2015

I'm aware that this issue has been closed now, but I thought I'd post anyway to explain why my plugin lacks a master branch. (I kinda wish you'd @mentioned me so I could have done so earlier.)

YCM-Generator originally had a master branch, and then later had a stable branch created. However, this resulted in many people cloning the master branch and either getting a bad impression of the project, or filing issues regarding it. (It's a development branch, it's going to be broken sometimes.) Consequently I renamed that branch to develop and made stable the default branch, to ensure that people either migrated to stable or made a conscious decision to use master. The naming of the branches was based on the git flow model, except that I did not name my production ready branch master since I thought that would cause confusion.

The reality is that the meaning and existence of the master branch varies from project to project, and relying purely on convention results in bad defaults, especially since orig/HEAD is already used to communicate the default branch to users.

At any rate, I just merged a PR to document this in YCM-Gen, so there's a workaround in place now (for my project anyway).

@starcraftman
Copy link
Contributor

@rdnetto Hi. Well I think @junegunn made his opinion clear, so we aren't likely to revisit this.

I find your explanation a bit odd. It seems like it would have been a lot less effort/confusion if you had just stabilized master branch to be your production code, then made develop branch as your dev line. Just my opinion though.

@junegunn
Copy link
Owner

@rdnetto I see your point. But this (allegedly false) assumption makes the code of vim-plug simpler and easier to maintain. It works 99.9% of the time, and it's not like we don't have a way around. Let's say that vim-plug requires you to be explicit about the branch to use and Plug 'something' is simply a shorthand notation of Plug 'something', { 'branch': 'master' }. Convention over configuration.

@rdnetto
Copy link

rdnetto commented Oct 30, 2015

@starcraftman That's fair enough - I just wanted to explain the opposing viewpoint, especially since I think it's only a matter of time until this comes up again.
My justification at the time was that master was normally used as the development branch, and I didn't want to create further confusion. At any rate, changing it now would be disruptive to my users, so I'm stuck with it.

@junegunn I don't doubt it - I thought about how you'd go about implementing the correct behaviour and it is much more painful. It's not the choice I'd make myself, but then it's not my project either.

At any rate, YCM-Gen's README includes a note about the correct line for vim-plug, so it's a moot point now.

ymattw added a commit to ymattw/profiles that referenced this issue Dec 25, 2015
piouPiouM added a commit to piouPiouM/LanguageClient-neovim that referenced this issue Dec 10, 2017
According junegunn/vim-plug#288 (comment) we have to precise the branch to clone if different of "master" in despite the fact that the "next" branch is set by default:

> `Plug 'something'` is simply a shorthand notation of `Plug 'something', { 'branch': 'master' }`

I was trying many times to install LanguageClient-neovim from scratch and invariably the master branch was cloned.
autozimu pushed a commit to autozimu/LanguageClient-neovim that referenced this issue Dec 10, 2017
According junegunn/vim-plug#288 (comment) we have to precise the branch to clone if different of "master" in despite the fact that the "next" branch is set by default:

> `Plug 'something'` is simply a shorthand notation of `Plug 'something', { 'branch': 'master' }`

I was trying many times to install LanguageClient-neovim from scratch and invariably the master branch was cloned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants