From 8b6a5a6c135dbd7e9759a03ff943d3b8e2002e9e Mon Sep 17 00:00:00 2001 From: Cyborus Date: Fri, 17 Nov 2023 15:54:37 -0500 Subject: [PATCH] don't look for remote if it obviously won't be there --- src/repo.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/repo.rs b/src/repo.rs index 4d0b572..54a4eb9 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -118,17 +118,13 @@ impl RepoCommand { host.join(&format!("{}/{}", login.username(), repo))? ); - let upstream = set_upstream.as_deref().unwrap_or("origin"); - - let repo = git2::Repository::open(".")?; - let mut remote = if set_upstream.is_some() || push { - repo.remote(upstream, new_repo.clone_url.as_str())? - } else { - repo.find_remote(upstream)? - }; - - if push { - remote.push::<&str>(&[], None)?; + if set_upstream.is_some() || push { + let repo = git2::Repository::open(".")?; + let upstream = set_upstream.as_deref().unwrap_or("origin"); + let mut remote = repo.remote(upstream, new_repo.clone_url.as_str())?; + if push { + remote.push::<&str>(&[], None)?; + } } } RepoCommand::Info => {