History

greatly improved performance for write-test. (#450)

It clones instead of re-creating the base repo from scratch.

Sebastian Thiel committed 4 years ago

Commit 2ec81751 parent 03877942 files · +9 −94Browse files

Unified · Split

2 files
  1. git-repository/tests/fixtures/make_fetch_repos.sh +2 −92
  2. git-repository/tests/remote/fetch.rs +7 −2
git-repository/tests/fixtures/make_fetch_repos.sh+2−92
@@ -1,96 +1,6 @@
11 set -eu -o pipefail
22
3−function tick () {
4− if test -z "${tick+set}"
5− then
6− tick=1112911993
7− else
8− tick=$(($tick + 60))
9− fi
10− GIT_COMMITTER_DATE="$tick -0700"
11− GIT_AUTHOR_DATE="$tick -0700"
12− export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
13−}
14−
15−GIT_AUTHOR_EMAIL=author@example.com
16−GIT_AUTHOR_NAME='A U Thor'
17−GIT_AUTHOR_DATE='1112354055 +0200'
18−TEST_COMMITTER_LOCALNAME=committer
19−TEST_COMMITTER_DOMAIN=example.com
20−GIT_COMMITTER_EMAIL=committer@example.com
21−GIT_COMMITTER_NAME='C O Mitter'
22−GIT_COMMITTER_DATE='1112354055 +0200'
23−
24−# runup to the correct count for ambigous commits
25−tick; tick; tick; tick; tick
26−
27−git init base
28−(
29− cd base
30− tick
31−
32− echo g > file
33− git add file && git commit -m $'G\n\n initial message'
34− git branch g
35−
36− tick
37− git checkout --orphan=h
38− echo h > file
39− git add file && git commit -m H
40−
41− tick
42− git checkout main
43− git merge h --allow-unrelated-histories || :
44− { echo g && echo h && echo d; } > file
45− git add file
46− git commit -m D
47− git branch d
48−
49− tick
50− git checkout --orphan=i
51− echo i > file
52− git add file && git commit -m I
53− git tag -m I-tag i-tag
54−
55− tick
56− git checkout --orphan=j
57− echo j > file
58− git add file && git commit -m J
59−
60− tick
61− git checkout i
62− git merge j --allow-unrelated-histories || :
63− { echo i && echo j && echo f; } > file
64− git add file
65− git commit -m F
66− git branch f
67−
68− tick
69− git checkout --orphan=e
70− echo e > file
71− git add file && git commit -m E
72−
73− tick
74− git checkout main
75− git merge e i --allow-unrelated-histories || :
76− { echo g && echo h && echo i && echo j && echo d && echo e && echo f && echo b; } > file
77− git add file && git commit -m B
78− git tag -m b-tag b-tag && git branch b
79−
80− tick
81− git checkout i
82− echo c >> file
83− git add file && git commit -m $'C\n\n message recent'
84− git branch c
85− git reset --hard i-tag
86−
87− tick
88− git checkout main
89− git merge c || :
90− { echo g && echo h && echo i && echo j && echo d && echo e && echo f && echo b && echo c && echo a; } > file
91− git add file && git commit -m A
92− git branch a
93−)
3+git clone --bare "${1:?First argument is the complex base repo from make_remote_repos.sh/base}" base
944
955 git clone --shared base clone-as-base-with-changes
966 (cd clone-as-base-with-changes
@@ -100,7 +10,7 @@ git clone --shared base clone-as-base-with-changes · 3 unmodified lines
10010 git tag -m "new-file introduction" v1.0
10111 )
10212
103−git clone --shared base two-origins
13+git clone --bare --shared base two-origins
10414 (cd two-origins
10515 git remote add changes-on-top-of-origin "$PWD/../clone-as-base-with-changes"
10616 )
git-repository/tests/remote/fetch.rs+7−2
@@ -1,5 +1,6 @@
11 #[cfg(feature = "blocking-network-client")]
22 mod blocking_io {
3+ use crate::remote;
34 use git_features::progress;
45 use git_repository as git;
56 use git_repository::remote::fetch;
@@ -10,7 +11,9 @@ mod blocking_io { · 4 unmodified lines
1011 pub(crate) fn repo_rw(name: &str) -> (git::Repository, git_testtools::tempfile::TempDir) {
1112 let dir = git_testtools::scripted_fixture_repo_writable_with_args(
1213 "make_fetch_repos.sh",
13− &[] as &[String],
14+ [git::path::realpath(remote::repo_path("base"))
15+ .unwrap()
16+ .to_string_lossy()],
1417 git_testtools::Creation::ExecuteScript,
1518 )
1619 .unwrap();
@@ -69,8 +72,10 @@ mod blocking_io { · 52 unmodified lines
6972 );
7073 assert_eq!(
7174 write_pack_bundle.index.index_hash,
72− hex_to_id("5e0c69c18bf1835edaa103622dc8637fd87ea2f3")
75+ hex_to_id("c75114f60ab2c9389916f3de1082bbaa47491e3b")
7376 );
77+ assert!(write_pack_bundle.data_path.map_or(false, |f| f.is_file()));
78+ assert!(write_pack_bundle.index_path.map_or(false, |f| f.is_file()));
7479 }
7580 fetch::Status::NoChange => unreachable!("we firmly expect changes here"),
7681 }