Skip to content

Commit

Permalink
feat: use gix-negotiate in fetch machinery.
Browse files Browse the repository at this point in the history
Thanks to it we are finally able to do pack negotiations just like git can,
as many rounds as it takes and with all available algorithms.
  • Loading branch information
Byron committed May 26, 2023
1 parent 701cf7a commit 3256523
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
42 changes: 42 additions & 0 deletions gix/tests/fixtures/make_remote_repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,45 @@ git clone --shared base detached-head
(cd detached-head
git checkout @~1
)

function commit() {
local message=${1:?first argument is the commit message}
local file="$message.t"
echo "$1" > "$file"
git add -- "$file"
tick
git commit -m "$message"
git tag "$message"
}

function optimize_repo() {
git commit-graph write --no-progress --reachable
git repack -adq
}

(mkdir multi_round && cd multi_round
git init -q server && cd server
commit to_fetch
cd ..

git init -q client && cd client
for i in $(seq 8); do
git checkout --orphan b$i &&
commit b$i.c0
done

for j in $(seq 19); do
for i in $(seq 8); do
git checkout b$i &&
commit b$i.c$j
done
done
optimize_repo
cd ..
(cd server
git fetch --no-tags "$PWD/../client" b1:refs/heads/b1
git checkout b1
commit commit-on-b1
optimize_repo
)
)
20 changes: 20 additions & 0 deletions gix/tests/remote/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod blocking_and_async_io {
use gix_protocol::maybe_async;

use crate::{
remote,
remote::{into_daemon_remote_if_async, spawn_git_daemon_if_async},
util::hex_to_id,
};
Expand Down Expand Up @@ -106,6 +107,25 @@ mod blocking_and_async_io {
Ok(())
}

// TODO: try this as maybe-async
#[test]
#[cfg(feature = "blocking-network-client")]
#[ignore = "fails because of improper negotiation (it's hacked to work for our cases)"]
fn fetch_with_multi_round_negotiation() -> crate::Result {
let repo = remote::repo("multi_round/client");
let server_repo = remote::repo("multi_round/server");
let changes = repo
.remote_at(server_repo.work_dir().expect("non-bare"))?
.with_refspecs(Some("refs/heads/*:refs/remotes/origin/*"), Fetch)?
.connect(Fetch)?
.prepare_fetch(gix::progress::Discard, Default::default())?
.with_dry_run(true)
.receive(gix::progress::Discard, &AtomicBool::default())?;

dbg!(changes);
Ok(())
}

#[maybe_async::test(
feature = "blocking-network-client",
async(feature = "async-network-client-async-std", async_std::test)
Expand Down

0 comments on commit 3256523

Please sign in to comment.