| @@ -9,8 +9,9 @@ mod error { · 8 unmodified lines |
| 9 | #[derive(Debug, thiserror::Error)] | 9 | #[derive(Debug, thiserror::Error)] |
| 10 | #[error("TBD")] | 10 | #[error("TBD")] |
| 11 | pub enum Error { | 11 | pub enum Error { |
| 12 | #[error("The configured pack.indexVersion is not valid. It must be 1 or 2, with 2 being the default{}", desired.map(|n| format!(" (but got {})", n)).unwrap_or_default())] | 12 | #[error("{message}{}", desired.map(|n| format!(" (got {})", n)).unwrap_or_default())] |
| 13 | PackIndexVersion { | 13 | Configuration { |
| | 14 | message: &'static str, |
| 14 | desired: Option<i64>, | 15 | desired: Option<i64>, |
| 15 | source: Option<git_config::value::Error>, | 16 | source: Option<git_config::value::Error>, |
| 16 | }, | 17 | }, |
| @@ -60,6 +61,7 @@ where · 43 unmodified lines |
| 60 | | 61 | |
| 61 | let repo = con.remote.repo; | 62 | let repo = con.remote.repo; |
| 62 | let _index_version = config::pack_index_version(repo)?; | 63 | let _index_version = config::pack_index_version(repo)?; |
| | 64 | let _thread_limit = config::index_threads(repo)?; |
| 63 | // let options = git_pack::bundle::write::Options { | 65 | // let options = git_pack::bundle::write::Options { |
| 64 | // thread_limit: ctx.thread_limit, | 66 | // thread_limit: ctx.thread_limit, |
| 65 | // index_version: git_pack::index::Version::V2, | 67 | // index_version: git_pack::index::Version::V2, |
| @@ -71,35 +73,7 @@ where · 5 unmodified lines |
| 71 | } | 73 | } |
| 72 | } | 74 | } |
| 73 | | 75 | |
| 74 | mod config { | 76 | mod config; |
| 75 | use super::Error; | | |
| 76 | use crate::Repository; | | |
| 77 | | | |
| 78 | pub fn pack_index_version(repo: &Repository) -> Result<git_pack::index::Version, Error> { | | |
| 79 | use git_pack::index::Version; | | |
| 80 | let lenient_config = repo.options.lenient_config; | | |
| 81 | Ok( | | |
| 82 | match repo.config.resolved.integer("pack", None, "indexVersion").transpose() { | | |
| 83 | Ok(Some(v)) if v == 1 => Version::V1, | | |
| 84 | Ok(Some(v)) if v == 2 => Version::V2, | | |
| 85 | Ok(None) => Version::V2, | | |
| 86 | Ok(Some(_)) | Err(_) if lenient_config => Version::V2, | | |
| 87 | Ok(Some(v)) => { | | |
| 88 | return Err(Error::PackIndexVersion { | | |
| 89 | desired: v.into(), | | |
| 90 | source: None, | | |
| 91 | }) | | |
| 92 | } | | |
| 93 | Err(err) => { | | |
| 94 | return Err(Error::PackIndexVersion { | | |
| 95 | desired: None, | | |
| 96 | source: err.into(), | | |
| 97 | }) | | |
| 98 | } | | |
| 99 | }, | | |
| 100 | ) | | |
| 101 | } | | |
| 102 | } | | |
| 103 | | 77 | |
| 104 | /// A structure to hold the result of the handshake with the remote and configure the upcoming fetch operation. | 78 | /// A structure to hold the result of the handshake with the remote and configure the upcoming fetch operation. |
| 105 | #[allow(dead_code)] | 79 | #[allow(dead_code)] |