-
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frame for instantiation of multi-pack-index (#279)
- Loading branch information
Showing
5 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,5 @@ pub use find_traits::{Find, FindExt}; | |
|
||
/// | ||
pub mod index; | ||
/// | ||
pub mod multi_index; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#![allow(missing_docs, unused)] | ||
use filebuffer::FileBuffer; | ||
|
||
/// A representation of an index file for multiple packs at the same time, typically stored in a file | ||
/// named 'multi-pack-index'. | ||
pub struct File { | ||
data: FileBuffer, | ||
path: std::path::PathBuf, | ||
} | ||
|
||
/// | ||
pub mod init { | ||
use crate::multi_index::File; | ||
use std::convert::TryFrom; | ||
use std::path::Path; | ||
|
||
mod error { | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Io(#[from] std::io::Error), | ||
} | ||
} | ||
pub use error::Error; | ||
|
||
impl File { | ||
pub fn at(path: impl AsRef<Path>) -> Result<Self, Error> { | ||
Self::try_from(path.as_ref()) | ||
} | ||
} | ||
|
||
impl TryFrom<&Path> for File { | ||
type Error = Error; | ||
|
||
fn try_from(path: &Path) -> Result<Self, Self::Error> { | ||
todo!() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
set -eu -o pipefail | ||
|
||
git init -q | ||
git config commit.gpgsign false | ||
|
||
function write_files() { | ||
local base_dir=${1:?directory to write them into} | ||
local num_files=${2:?amount of files to write} | ||
local nonce=${3:?something to make files more unique} | ||
|
||
mkdir -p "$base_dir" | ||
for file_id in $(seq -w "$num_files"); do | ||
seq "$file_id" > "$base_dir/$file_id" | ||
echo "$nonce" >> "$base_dir/$file_id" | ||
done | ||
} | ||
|
||
dirs=(. a b c a/a a/b a/c a/a/a) | ||
rounds=15 | ||
|
||
git checkout -q -b main | ||
for round in $(seq $rounds); do | ||
dir_index=$(( round % ${#dirs[@]} )) | ||
num_files=$(( (round + 1) * 6 )) | ||
write_files "${dirs[$dir_index]}" $num_files "$round" | ||
git add . | ||
git commit -qm "$round $num_files" | ||
done | ||
|
||
echo hello world > referee | ||
git add referee | ||
git commit -qm "to be forgotten" | ||
git tag -m "a tag object" referrer | ||
git reset --hard HEAD~1 | ||
|
||
# speed up all access by creating a pack | ||
git gc --aggressive | ||
git multi-pack-index write |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ mod bundle; | |
mod data; | ||
mod index; | ||
mod iter; | ||
mod multi_index; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#[test] | ||
#[ignore] | ||
fn access() { | ||
let path = git_testtools::scripted_fixture_repo_read_only("make_pack_gen_repo_multi_index.sh") | ||
.unwrap() | ||
.join(".git/objects/pack/multi-pack-index"); | ||
let _file = git_pack::multi_index::File::at(path).unwrap(); | ||
} |