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

Use the default branch instead of master when branch isn't set explicitly #1005

Closed
6 of 11 tasks
leitzler opened this issue Aug 13, 2020 · 12 comments · Fixed by #1272
Closed
6 of 11 tasks

Use the default branch instead of master when branch isn't set explicitly #1005

leitzler opened this issue Aug 13, 2020 · 12 comments · Fixed by #1272

Comments

@leitzler
Copy link

As several repositories are already moving away from having the default branch named master, I suggest that vim-go should use the repository default branch when the user hasn't explicitly set a branch.

I'm using https://github.com/govim/govim (installed via vim-plug) that recently changed from master to main as the default branch. A workaround to get things working was to rename the local branch inside .vim/plugged/govim but I recently noticed that vim-plug changes branch back to master if I don't have a branch name set.

i.e.

" This will give me the default branch instead of 'master'
Plug 'govim/govim' 

" .. while this still works
Plug 'govim/govim', { 'branch': 'development' }

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jun  7 2020 01:33:04)
macOS version
Included patches: 1-916
Compiled by leitzler@machine.int.leitzler.net
Huge version without GUI.  Features included (+) or not (-):
+acl               +cryptv            +fork()            +modify_fname      +persistent_undo   +syntax            +visualextra
+arabic            -cscope            -gettext           +mouse             +popupwin          +tag_binary        +viminfo
+autocmd           +cursorbind        -hangul_input      -mouseshape        +postscript        -tag_old_static    +vreplace
+autochdir         +cursorshape       +iconv             +mouse_dec         +printer           -tag_any_white     +wildignore
-autoservername    +dialog_con        +insert_expand     -mouse_gpm         +profile           -tcl               +wildmenu
-balloon_eval      +diff              +ipv6              -mouse_jsbterm     -python            +termguicolors     +windows
+balloon_eval_term +digraphs          +job               +mouse_netterm     -python3           +terminal          +writebackup
-browse            -dnd               +jumplist          +mouse_sgr         +quickfix          +terminfo          -X11
++builtin_terms    -ebcdic            +keymap            -mouse_sysmouse    +reltime           +termresponse      -xfontset
+byte_offset       +emacs_tags        +lambda            +mouse_urxvt       +rightleft         +textobjects       -xim
+channel           +eval              +langmap           +mouse_xterm       -ruby              +textprop          -xpm
+cindent           +ex_extra          +libcall           +multi_byte        +scrollbind        +timers            -xsmp
-clientserver      +extra_search      +linebreak         +multi_lang        +signs             +title             -xterm_clipboard
+clipboard         -farsi             +lispindent        -mzscheme          +smartindent       -toolbar           -xterm_save
+cmdline_compl     +file_in_path      +listcmds          +netbeans_intg     -sound             +user_commands
+cmdline_hist      +find_in_path      +localmap          +num64             +spell             +vartabs
+cmdline_info      +float             -lua               +packages          +startuptime       +vertsplit
+comments          +folding           +menu              +path_extra        +statusline        +virtualedit
+conceal           -footer            +mksession         -perl              -sun_workshop      +visual
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -O2   -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc    -o vim        -lm -lncurses  -liconv -framework AppKit
  • Type:
    • Bug
    • Enhancement
    • Feature Request
    • Question
  • OS:
    • All/Other
    • Linux
    • OS X
    • Windows
  • Vim:
    • Terminal Vim
    • GVim
    • Neovim
@mschilli87
Copy link

Also see #854.

@leitzler
Copy link
Author

Also see #854.

Oh, thanks. I did look through the issues but must have missed it, apologies for that!

With regards to the current work by GitHub related to this, it might be time to give it another round of thoughts?

@leitzler
Copy link
Author

from #854 (comment):

This was discussed several times in the past. You should be able to find some related issues here. While I do not disagree with the suggestion, implementing it correctly without complicating the code too much is actually not trivial (e.g. branch validation in PlugStatus, how to find out if the default branch has been changed in the origin after we cloned it, etc.), so it's not exactly something I'd like to look into now. But patches are welcome.

FWIW - It seems like git remote set-head origin -a is a way to set the local default branch to whatever it is/has changed to remotely.

@myitcv
Copy link

myitcv commented Aug 15, 2020

git remote set-head origin -a

This is an excellent tip in general, but seems like the perfect solution here?

@junegunn
Copy link
Owner

Fixed in #1007

@leitzler
Copy link
Author

leitzler commented Sep 1, 2020

I suggest re-opening this as per #1007 (comment)

@junegunn
Copy link
Owner

junegunn commented Sep 2, 2020

@leitzler Are you interested in sending a pull request?

@leitzler
Copy link
Author

@junegunn I don't think I know vimscript well enough to get it right unfortunately (and I seem to have missed the notification for this one, sorry about it).

Revisited this since a govim user recently ran into this issue again.

@matthewarmand
Copy link

@junegunn I just ran into this issue dealing with the Black plugin. Are there plans to tag a new release of vim-plug soon to get this out, or are you waiting on the git remote set-head origin -a fix proposed above (and in the merged PR)?

@mangelozzi
Copy link

I would say this is more of a bug than a feature, because I can't install a third of the required plugins.

@mschilli87
Copy link

mschilli87 commented Feb 3, 2023

@mangelozzi: What do you mean? Can you give an example of a plugin you 'can't install' due to this issue (incl. the corresponding section from your config)?

@junegunn
Copy link
Owner

junegunn commented Mar 4, 2024

From #1007 (comment)

Since a lot of repositories also follow GitHubs rename instructions I suggest that vim-plug also run git remote set-head origin -a each update to ensure that the remote default branch isn't stale.

This is probably the only way to solve the changed default branch problem. It will make the update slower though.

junegunn added a commit that referenced this issue Mar 6, 2024
Fix #1005

vim-plug will now run `git remote set-head origin -a` on PlugUpdate to
keep track of the default branch of the origin, so that it can still
update even if the default branch has changed.

This additional command will slow down the update process, but this is
the unavoidable price to pay for the correctness of the task. However,
vim-plug will run checkout and merge commands in parallel, so this
improvement will slightly offset the slowdown.
junegunn added a commit that referenced this issue Mar 6, 2024
Fix #1005

vim-plug will now run `git remote set-head origin -a` on PlugUpdate to
keep track of the default branch of the origin, so that it can still
update a plugin even if its default branch has changed.

This additional command will slow down the update process, but this is
an unavoidable price to pay for the correctness of the task. However,
vim-plug will run checkout and merge commands in parallel, so this
improvement will slightly offset the slowdown.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants