3 test_description
='push to a repository that borrows from elsewhere'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
11 test_expect_success setup
'
23 git commit -m initial &&
24 git push ../alice-pub main
27 # Project Bob is a fork of project Alice
32 mkdir -p objects/info &&
33 echo ../../alice-pub/objects >objects/info/alternates
35 git clone alice-pub bob-work &&
38 git push ../bob-pub main
42 test_expect_success
'alice works and pushes' '
46 git commit -a -m second &&
47 git push ../alice-pub :
51 test_expect_success
'bob fetches from alice, works and pushes' '
53 # Bob acquires what Alice did in his work tree first.
54 # Even though these objects are not directly in
55 # the public repository of Bob, this push does not
56 # need to send the commit Bob received from Alice
57 # to his public repository, as all the object Alice
58 # has at her public repository are available to it
61 git pull ../alice-pub main &&
62 echo more bob >file &&
63 git commit -a -m third &&
67 # Check that the second commit by Alice is not sent
71 second=$(git rev-parse HEAD^) &&
72 rm -f objects/info/alternates &&
73 test_must_fail git cat-file -t $second &&
74 echo ../../alice-pub/objects >objects/info/alternates
78 test_expect_success
'clean-up in case the previous failed' '
81 echo ../../alice-pub/objects >objects/info/alternates
85 test_expect_success
'alice works and pushes again' '
87 # Alice does not care what Bob does. She does not
88 # even have to be aware of his existence. She just
89 # keeps working and pushing
91 echo more alice >file &&
92 git commit -a -m fourth &&
93 git push ../alice-pub :
97 test_expect_success
'bob works and pushes' '
99 # This time Bob does not pull from Alice, and
100 # the main branch at her public repository points
101 # at a commit Bob does not know about. This should
102 # not prevent the push by Bob from succeeding.
104 echo yet more bob >file &&
105 git commit -a -m fifth &&
106 git push ../bob-pub :
110 test_expect_success
'alice works and pushes yet again' '
112 # Alice does not care what Bob does. She does not
113 # even have to be aware of his existence. She just
114 # keeps working and pushing
116 echo more and more alice >file &&
117 git commit -a -m sixth.1 &&
118 echo more and more alice >>file &&
119 git commit -a -m sixth.2 &&
120 echo more and more alice >>file &&
121 git commit -a -m sixth.3 &&
122 git push ../alice-pub :
126 test_expect_success
'bob works and pushes again' '
129 git cat-file commit main >../bob-work/commit
132 # This time Bob does not pull from Alice, and
133 # the main branch at her public repository points
134 # at a commit Bob does not fully know about, but
135 # he happens to have the commit object (but not the
136 # necessary tree) in his repository from Alice.
137 # This should not prevent the push by Bob from
140 git hash-object -t commit -w commit &&
141 echo even more bob >file &&
142 git commit -a -m seventh &&
143 git push ../bob-pub :