git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob 257cea9610825348c1ab5c1989031d422cfda73d 5375 bytes (raw)
name: t/t9904-git-prime-clone.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
 
#!/bin/sh

test_description='tests for git prime-clone'
. ./test-lib.sh

ROOT_PATH="$PWD"
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd

test_expect_success 'resume fails for no parameters' '
	test_must_fail git clone --resume
'

test_expect_success 'resume fails with other options' '
	test_must_fail git clone --resume --bare
'

test_expect_success 'resume fails for excess parameters' '
	test_must_fail git clone --resume a b
'

test_expect_success 'resume fails for nonexistent directory' '
	test_must_fail git clone --resume nonexistent
'

test_expect_success 'setup repo and httpd' '
	mkdir server &&
	cd server &&
	git init &&
	echo "content\\n" >example.c &&
	git add example.c &&
	git commit -m "I am a packed commit" &&
	git repack . &&
	git config --local http.primeclone true &&
	git config --local primeclone.url \
		$HTTPD_URL/server/.git/objects/pack/$(find .git/objects/pack/*.pack -printf "%f") &&
	git config --local primeclone.filetype pack &&
	echo "content\\n" >example2.c &&
	echo "new content\\n" >example.c &&
	git add example.c example2.c &&
	git commit -m "I am an unpacked commit" &&
	cd - &&
	mv server "$HTTPD_DOCUMENT_ROOT_PATH"
'

test_expect_success 'prime-clone works http' '
	git clone $HTTPD_URL/smart/server client &&
	rm -r client
'

test_expect_success 'prime-clone falls back not permitted' '
	cd "$HTTPD_DOCUMENT_ROOT_PATH/server" &&
	git config --local http.primeclone false &&
	cd - &&
	git clone $HTTPD_URL/smart/server client &&
	rm -r client &&
	cd "$HTTPD_DOCUMENT_ROOT_PATH/server" &&
	git config --local http.primeclone true &&
	cd -
'

test_expect_success 'prime-clone falls back not enabled' '
	cd "$HTTPD_DOCUMENT_ROOT_PATH/server" &&
	git config --local primeclone.enabled 0 &&
	cd - &&
	git clone $HTTPD_URL/smart/server client &&
	rm -r client &&
	cd "$HTTPD_DOCUMENT_ROOT_PATH/server" &&
	git config --local --unset-all primeclone.enabled &&
	cd -
'

test_expect_success 'prime-clone falls back incorrect config' '
	cd "$HTTPD_DOCUMENT_ROOT_PATH/server" &&
	git config --local --unset-all primeclone.filetype &&
	cd - &&
	git clone $HTTPD_URL/smart/server client &&
	rm -r client &&
	cd "$HTTPD_DOCUMENT_ROOT_PATH/server" &&
	git config --local primeclone.filetype pack &&
	cd -
'

test_expect_success 'clone resume fails in complete/unmarked directory' '
	git clone $HTTPD_URL/smart/server client &&
	test_must_fail git clone --resume client &&
	rm -r client
'

test_expect_success 'clone resume works with marked repo (work dir, normal)' '
	git clone $HTTPD_URL/smart/server client &&
	cd client &&
	rm .git/objects/pack/*.idx &&
	echo -n "$HTTPD_URL/server/" > .git/RESUMABLE &&
	find .git/objects/pack/*.pack >> .git/RESUMABLE &&
	echo "pack" >> .git/RESUMABLE &&
	mv $(find .git/objects/pack/*.pack) $(find .git/objects/pack/*.pack).tmp &&
	sed -i "2,$ d" $(find .git/objects/pack/*.pack.tmp) &&
	rm * &&
	git clone --resume . &&
	cd - &&
	rm -r client
'

test_expect_success 'clone resume works with marked repo (git dir, normal)' '
	git clone $HTTPD_URL/smart/server client &&
	cd client &&
	rm .git/objects/pack/*.idx &&
	echo -n "$HTTPD_URL/server/" > .git/RESUMABLE &&
	find .git/objects/pack/*.pack >> .git/RESUMABLE &&
	echo "pack" >> .git/RESUMABLE &&
	mv $(find .git/objects/pack/*.pack) $(find .git/objects/pack/*.pack).tmp &&
	sed -i "2,$ d" $(find .git/objects/pack/*.pack.tmp) &&
	rm * &&
	git clone --resume .git &&
	cd - &&
	rm -r client
'

test_expect_success 'clone resume works inside marked repo (git dir, normal)' '
	git clone $HTTPD_URL/smart/server client &&
	cd client &&
	rm .git/objects/pack/*.idx &&
	echo -n "$HTTPD_URL/server/" > .git/RESUMABLE &&
	find .git/objects/pack/*.pack >> .git/RESUMABLE &&
	echo "pack" >> .git/RESUMABLE &&
	mv $(find .git/objects/pack/*.pack) $(find .git/objects/pack/*.pack).tmp &&
	sed -i "2,$ d" $(find .git/objects/pack/*.pack.tmp) &&
	rm * &&
	cd .git &&
	git clone --resume . &&
	cd ../.. &&
	rm -r client
'

test_expect_success 'clone resume works with marked repo (work dir, split)' '
	git clone --separate-git-dir=separate_dir.git \
		$HTTPD_URL/smart/server client &&
	cd separate_dir.git &&
	rm objects/pack/*.idx &&
	echo -n "$HTTPD_URL/server/" > RESUMABLE &&
	echo ".git/$(find objects/pack/*.pack)" >> RESUMABLE &&
	echo "pack" >> RESUMABLE &&
	mv $(find objects/pack/*.pack) $(find objects/pack/*.pack).tmp &&
	sed -i "2,$ d" $(find objects/pack/*.pack.tmp) &&
	cd ../client &&
	rm * &&
	cd .. &&
	git clone --resume client &&
	rm -r client separate_dir.git
'

test_expect_success 'clone resume works with marked repo (git dir, split)' '
	git clone --separate-git-dir=separate_dir.git \
		$HTTPD_URL/smart/server client &&
	cd separate_dir.git &&
	rm objects/pack/*.idx &&
	echo -n "$HTTPD_URL/server/" > RESUMABLE &&
	echo ".git/$(find objects/pack/*.pack)" >> RESUMABLE &&
	echo "pack" >> RESUMABLE &&
	mv $(find objects/pack/*.pack) $(find objects/pack/*.pack).tmp &&
	sed -i "2,$ d" $(find objects/pack/*.pack.tmp) &&
	cd ../client &&
	rm * &&
	cd .. &&
	git clone --resume separate_dir.git &&
	rm -r client separate_dir.git
'

test_expect_success 'prime-clone falls back unusable file' '
	cd "$HTTPD_DOCUMENT_ROOT_PATH/server" &&
	git config --local primeclone.url $HTTPD_URL/server/.git/HEAD &&
	cd - &&
	git clone $HTTPD_URL/smart/server client &&
	rm -r client &&
	cd "$HTTPD_DOCUMENT_ROOT_PATH/server" &&
	cd -
'

stop_httpd
test_done

debug log:

solving 257cea9 ...
found 257cea9 in https://public-inbox.org/git/1473984742-12516-12-git-send-email-kevin.m.wern@gmail.com/

applying [1/1] https://public-inbox.org/git/1473984742-12516-12-git-send-email-kevin.m.wern@gmail.com/
diff --git a/t/t9904-git-prime-clone.sh b/t/t9904-git-prime-clone.sh
new file mode 100755
index 0000000..257cea9

Checking patch t/t9904-git-prime-clone.sh...
Applied patch t/t9904-git-prime-clone.sh cleanly.

index at:
100755 257cea9610825348c1ab5c1989031d422cfda73d	t/t9904-git-prime-clone.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).