From 29bf022218f72157e1921412ae6ede598733b6fb Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 21 Jul 2020 19:08:16 -0400 Subject: [PATCH] Store Repository in git config struct --- src/git_config.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/git_config.rs b/src/git_config.rs index c6ef9c0cf..fdd28af15 100644 --- a/src/git_config.rs +++ b/src/git_config.rs @@ -7,6 +7,7 @@ use git2; pub struct GitConfig { config: git2::Config, pub enabled: bool, + pub repo: Option, } impl GitConfig { @@ -15,7 +16,7 @@ impl GitConfig { Ok(dir) => git2::Repository::discover(dir).ok(), _ => None, }; - let config = match repo { + let config = match &repo { Some(repo) => repo.config().ok(), None => git2::Config::open_default().ok(), }; @@ -27,6 +28,7 @@ impl GitConfig { }); Some(Self { config, + repo, enabled: true, }) } @@ -38,6 +40,7 @@ impl GitConfig { pub fn from_path(path: &Path) -> Self { Self { config: git2::Config::open(path).unwrap(), + repo: None, enabled: true, } }