Blame


1 c811fd62 2024-05-05 stsp #!/bin/sh
2 c811fd62 2024-05-05 stsp #
3 c811fd62 2024-05-05 stsp # Copyright (c) 2024 Stefan Sperling <stsp@openbsd.org>
4 c811fd62 2024-05-05 stsp #
5 c811fd62 2024-05-05 stsp # Permission to use, copy, modify, and distribute this software for any
6 c811fd62 2024-05-05 stsp # purpose with or without fee is hereby granted, provided that the above
7 c811fd62 2024-05-05 stsp # copyright notice and this permission notice appear in all copies.
8 c811fd62 2024-05-05 stsp #
9 c811fd62 2024-05-05 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 c811fd62 2024-05-05 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 c811fd62 2024-05-05 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 c811fd62 2024-05-05 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 c811fd62 2024-05-05 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 c811fd62 2024-05-05 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 c811fd62 2024-05-05 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 c811fd62 2024-05-05 stsp
17 c811fd62 2024-05-05 stsp . ../cmdline/common.sh
18 c811fd62 2024-05-05 stsp . ./common.sh
19 c811fd62 2024-05-05 stsp
20 c811fd62 2024-05-05 stsp test_fetch_with_git_history_walk() {
21 c811fd62 2024-05-05 stsp local testroot=`test_init fetch_with_git_history_walk 1`
22 c811fd62 2024-05-05 stsp
23 c811fd62 2024-05-05 stsp git clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone \
24 c811fd62 2024-05-05 stsp 2> $testroot/stderr
25 c811fd62 2024-05-05 stsp ret=$?
26 c811fd62 2024-05-05 stsp if [ $ret -ne 0 ]; then
27 c811fd62 2024-05-05 stsp echo "git clone failed unexpectedly" >&2
28 c811fd62 2024-05-05 stsp test_done "$testroot" "1"
29 c811fd62 2024-05-05 stsp return 1
30 c811fd62 2024-05-05 stsp fi
31 c811fd62 2024-05-05 stsp
32 c811fd62 2024-05-05 stsp # Create new commits on a branch which doesn't exist in gotd repo.
33 c811fd62 2024-05-05 stsp # We want Git to send a flush-pkt followed by more have-lines. This
34 c811fd62 2024-05-05 stsp # requires at least 16 commits (fetch-pack.c:INITIAL_FLUSH 16).
35 c811fd62 2024-05-05 stsp git -C $testroot/repo-clone branch newbranch
36 c811fd62 2024-05-05 stsp for i in `seq 24`; do
37 c811fd62 2024-05-05 stsp echo $i >> $testroot/repo-clone/file$i
38 c811fd62 2024-05-05 stsp git -C $testroot/repo-clone add file$i
39 c811fd62 2024-05-05 stsp git_commit $testroot/repo-clone -m "add file$i"
40 c811fd62 2024-05-05 stsp ret=$?
41 c811fd62 2024-05-05 stsp if [ $ret -ne 0 ]; then
42 c811fd62 2024-05-05 stsp echo "git commit failed unexpectedly" >&2
43 c811fd62 2024-05-05 stsp test_done "$testroot" "1"
44 c811fd62 2024-05-05 stsp return 1
45 c811fd62 2024-05-05 stsp fi
46 c811fd62 2024-05-05 stsp done
47 c811fd62 2024-05-05 stsp
48 c811fd62 2024-05-05 stsp git clone -q ${GOTD_TEST_REPO_URL} $testroot/repo-clone2 \
49 c811fd62 2024-05-05 stsp 2> $testroot/stderr
50 c811fd62 2024-05-05 stsp ret=$?
51 c811fd62 2024-05-05 stsp if [ $ret -ne 0 ]; then
52 c811fd62 2024-05-05 stsp echo "git clone failed unexpectedly" >&2
53 c811fd62 2024-05-05 stsp test_done "$testroot" "1"
54 c811fd62 2024-05-05 stsp return 1
55 c811fd62 2024-05-05 stsp fi
56 c811fd62 2024-05-05 stsp
57 c811fd62 2024-05-05 stsp # create new commits on main branch, and push to gotd
58 c811fd62 2024-05-05 stsp for i in `seq 2`; do
59 c811fd62 2024-05-05 stsp echo $i >> $testroot/repo-clone2/file$i
60 c811fd62 2024-05-05 stsp git -C $testroot/repo-clone2 add file$i
61 c811fd62 2024-05-05 stsp git_commit $testroot/repo-clone2 -m "add file$i"
62 c811fd62 2024-05-05 stsp ret=$?
63 c811fd62 2024-05-05 stsp if [ $ret -ne 0 ]; then
64 c811fd62 2024-05-05 stsp echo "git commit failed unexpectedly" >&2
65 c811fd62 2024-05-05 stsp test_done "$testroot" "1"
66 c811fd62 2024-05-05 stsp return 1
67 c811fd62 2024-05-05 stsp fi
68 c811fd62 2024-05-05 stsp done
69 c811fd62 2024-05-05 stsp
70 c811fd62 2024-05-05 stsp git -C $testroot/repo-clone2 push -q origin main
71 c811fd62 2024-05-05 stsp ret=$?
72 c811fd62 2024-05-05 stsp if [ $ret -ne 0 ]; then
73 c811fd62 2024-05-05 stsp echo "git push failed unexpectedly" >&2
74 c811fd62 2024-05-05 stsp test_done "$testroot" "1"
75 c811fd62 2024-05-05 stsp return 1
76 c811fd62 2024-05-05 stsp fi
77 c811fd62 2024-05-05 stsp
78 c811fd62 2024-05-05 stsp # Fetching changes into the first repository clone should work.
79 c811fd62 2024-05-05 stsp # This used to fail because gotd rejected additional have-lines
80 c811fd62 2024-05-05 stsp # once Git had sent a flush-pkt.
81 c811fd62 2024-05-05 stsp git -C $testroot/repo-clone fetch -q 2> $testroot/stderr
82 c811fd62 2024-05-05 stsp ret=$?
83 c811fd62 2024-05-05 stsp if [ $ret -ne 0 ]; then
84 c811fd62 2024-05-05 stsp echo "git fetch failed unexpectedly" >&2
85 c811fd62 2024-05-05 stsp test_done "$testroot" "1"
86 c811fd62 2024-05-05 stsp return 1
87 c811fd62 2024-05-05 stsp fi
88 c811fd62 2024-05-05 stsp
89 c811fd62 2024-05-05 stsp test_done "$testroot" "0"
90 c811fd62 2024-05-05 stsp }
91 c811fd62 2024-05-05 stsp
92 c811fd62 2024-05-05 stsp run_test test_fetch_with_git_history_walk