From 82a9af133ce15afc232a9e754898a8ba252780e6 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 7 Mar 2023 19:08:53 -0500 Subject: [PATCH] Reject remotes without appropriate push/fetch key Verifying by URL is insufficient, as git clone --bare will create a remote with a URL but not a fetch key, resulting in no refs in refs/remotes/. Resolves: https://github.com/tpope/vim-fugitive/issues/2129 --- autoload/fugitive.vim | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 8e4998e..3af2dde 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -2803,18 +2803,14 @@ function! fugitive#BufReadStatus(...) abort let b:fugitive_files['Unstaged'][dict.filename] = dict endfor - let fetch_remote = FugitiveConfigGet('branch.' . branch . '.remote', config) - if empty(fetch_remote) && !empty(s:Tree()) && !empty(FugitiveConfigGet('remote.origin.url', config)) - let fetch_remote = 'origin' + let fetch_remote = config.Get('branch.' . branch . '.remote', 'origin') + let push_remote = config.Get('branch.' . branch . '.pushRemote', + \ config.Get('remote.pushDefault', fetch_remote)) + if empty(config.Get('remote.' . fetch_remote . '.fetch')) + let fetch_remote = '' endif - let push_remote = FugitiveConfigGet('branch.' . branch . '.pushRemote', config) - if empty(push_remote) - let push_remote = FugitiveConfigGet('remote.pushDefault', config) - if empty(push_remote) - let push_remote = fetch_remote - elseif empty(FugitiveConfigGet('remote.' . push_remote . '.url', config)) - let push_remote = '' - endif + if empty(config.Get('remote.' . push_remote . '.push', config.Get('remote.' . push_remote . '.fetch'))) + let push_remote = '' endif let pull_type = 'Pull'