It clones instead of re-creating the base repo from scratch.
Unified · Split
| @@ -1,96 +1,6 @@ | |||
| 1 | set -eu -o pipefail | 1 | set -eu -o pipefail |
| 2 | 2 | ||
| 3 | function tick () { | 3 | git clone --bare "${1:?First argument is the complex base repo from make_remote_repos.sh/base}" base |
| 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 | ) | ||
| 94 | 4 | ||
| 95 | git clone --shared base clone-as-base-with-changes | 5 | git clone --shared base clone-as-base-with-changes |
| 96 | (cd clone-as-base-with-changes | 6 | (cd clone-as-base-with-changes |
| @@ -100,7 +10,7 @@ git clone --shared base clone-as-base-with-changes · 3 unmodified lines | |||
| 100 | git tag -m "new-file introduction" v1.0 | 10 | git tag -m "new-file introduction" v1.0 |
| 101 | ) | 11 | ) |
| 102 | 12 | ||
| 103 | git clone --shared base two-origins | 13 | git clone --bare --shared base two-origins |
| 104 | (cd two-origins | 14 | (cd two-origins |
| 105 | git remote add changes-on-top-of-origin "$PWD/../clone-as-base-with-changes" | 15 | git remote add changes-on-top-of-origin "$PWD/../clone-as-base-with-changes" |
| 106 | ) | 16 | ) |
| @@ -1,5 +1,6 @@ | |||
| 1 | #[cfg(feature = "blocking-network-client")] | 1 | #[cfg(feature = "blocking-network-client")] |
| 2 | mod blocking_io { | 2 | mod blocking_io { |
| 3 | use crate::remote; | ||
| 3 | use git_features::progress; | 4 | use git_features::progress; |
| 4 | use git_repository as git; | 5 | use git_repository as git; |
| 5 | use git_repository::remote::fetch; | 6 | use git_repository::remote::fetch; |
| @@ -10,7 +11,9 @@ mod blocking_io { · 4 unmodified lines | |||
| 10 | pub(crate) fn repo_rw(name: &str) -> (git::Repository, git_testtools::tempfile::TempDir) { | 11 | pub(crate) fn repo_rw(name: &str) -> (git::Repository, git_testtools::tempfile::TempDir) { |
| 11 | let dir = git_testtools::scripted_fixture_repo_writable_with_args( | 12 | let dir = git_testtools::scripted_fixture_repo_writable_with_args( |
| 12 | "make_fetch_repos.sh", | 13 | "make_fetch_repos.sh", |
| 13 | &[] as &[String], | 14 | [git::path::realpath(remote::repo_path("base")) |
| 15 | .unwrap() | ||
| 16 | .to_string_lossy()], | ||
| 14 | git_testtools::Creation::ExecuteScript, | 17 | git_testtools::Creation::ExecuteScript, |
| 15 | ) | 18 | ) |
| 16 | .unwrap(); | 19 | .unwrap(); |
| @@ -69,8 +72,10 @@ mod blocking_io { · 52 unmodified lines | |||
| 69 | ); | 72 | ); |
| 70 | assert_eq!( | 73 | assert_eq!( |
| 71 | write_pack_bundle.index.index_hash, | 74 | write_pack_bundle.index.index_hash, |
| 72 | hex_to_id("5e0c69c18bf1835edaa103622dc8637fd87ea2f3") | 75 | hex_to_id("c75114f60ab2c9389916f3de1082bbaa47491e3b") |
| 73 | ); | 76 | ); |
| 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())); | ||
| 74 | } | 79 | } |
| 75 | fetch::Status::NoChange => unreachable!("we firmly expect changes here"), | 80 | fetch::Status::NoChange => unreachable!("we firmly expect changes here"), |
| 76 | } | 81 | } |