git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob 2da8ca6f2bba573a74952e12e622c9b5524d659c 4397 bytes (raw)
name: t/t9211-scalar-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
 
#!/bin/sh

test_description='test the `scalar clone` subcommand'

. ./test-lib.sh
. "${TEST_DIRECTORY}/lib-terminal.sh"

GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt,launchctl:true,schtasks:true"
export GIT_TEST_MAINT_SCHEDULER

test_expect_success 'set up repository to clone' '
	rm -rf .git &&
	git init to-clone &&
	(
		cd to-clone &&
		git branch -m base &&

		test_commit first &&
		test_commit second &&
		test_commit third &&

		git switch -c parallel first &&
		mkdir -p 1/2 &&
		test_commit 1/2/3 &&

		git switch base &&

		# By default, permit
		git config uploadpack.allowfilter true &&
		git config uploadpack.allowanysha1inwant true
	)
'

cleanup_clone () {
	rm -rf "$1"
}

test_expect_success 'creates content in enlistment root' '
	enlistment=cloned &&

	scalar clone "file://$(pwd)/to-clone" $enlistment &&
	ls -A $enlistment >enlistment-root &&
	test_line_count = 1 enlistment-root &&
	test_path_is_dir $enlistment/src &&
	test_path_is_dir $enlistment/src/.git &&

	cleanup_clone $enlistment
'

test_expect_success 'with spaces' '
	enlistment="cloned with space" &&

	scalar clone "file://$(pwd)/to-clone" "$enlistment" &&
	test_path_is_dir "$enlistment" &&
	test_path_is_dir "$enlistment/src" &&
	test_path_is_dir "$enlistment/src/.git" &&

	cleanup_clone "$enlistment"
'

test_expect_success 'partial clone if supported by server' '
	enlistment=partial-clone &&

	scalar clone "file://$(pwd)/to-clone" $enlistment &&

	(
		cd $enlistment/src &&

		# Two promisor packs: one for refs, the other for blobs
		ls .git/objects/pack/pack-*.promisor >promisorlist &&
		test_line_count = 2 promisorlist
	) &&

	cleanup_clone $enlistment
'

test_expect_success 'fall back on full clone if partial unsupported' '
	enlistment=no-partial-support &&

	test_config -C to-clone uploadpack.allowfilter false &&
	test_config -C to-clone uploadpack.allowanysha1inwant false &&

	scalar clone "file://$(pwd)/to-clone" $enlistment 2>err &&
	grep "filtering not recognized by server, ignoring" err &&

	(
		cd $enlistment/src &&

		# Still get a refs promisor file, but none for blobs
		ls .git/objects/pack/pack-*.promisor >promisorlist &&
		test_line_count = 1 promisorlist
	) &&

	cleanup_clone $enlistment
'

test_expect_success 'initializes sparse-checkout by default' '
	enlistment=sparse &&

	scalar clone "file://$(pwd)/to-clone" $enlistment &&
	(
		cd $enlistment/src &&
		test_cmp_config true core.sparseCheckout &&
		test_cmp_config true core.sparseCheckoutCone
	) &&

	cleanup_clone $enlistment
'

test_expect_success '--full-clone does not create sparse-checkout' '
	enlistment=full-clone &&

	scalar clone --full-clone "file://$(pwd)/to-clone" $enlistment &&
	(
		cd $enlistment/src &&
		test_cmp_config "" --default "" core.sparseCheckout &&
		test_cmp_config "" --default "" core.sparseCheckoutCone
	) &&

	cleanup_clone $enlistment
'

test_expect_success '--single-branch clones HEAD only' '
	enlistment=single-branch &&

	scalar clone --single-branch "file://$(pwd)/to-clone" $enlistment &&
	(
		cd $enlistment/src &&
		git for-each-ref refs/remotes/origin >out &&
		test_line_count = 1 out &&
		grep "refs/remotes/origin/base" out
	) &&

	cleanup_clone $enlistment
'

test_expect_success '--no-single-branch clones all branches' '
	enlistment=no-single-branch &&

	scalar clone --no-single-branch "file://$(pwd)/to-clone" $enlistment &&
	(
		cd $enlistment/src &&
		git for-each-ref refs/remotes/origin >out &&
		test_line_count = 2 out &&
		grep "refs/remotes/origin/base" out &&
		grep "refs/remotes/origin/parallel" out
	) &&

	cleanup_clone $enlistment
'

test_expect_success TTY 'progress with tty' '
	enlistment=progress1 &&

	test_config -C to-clone uploadpack.allowfilter true &&
	test_config -C to-clone uploadpack.allowanysha1inwant true &&

	test_terminal env GIT_PROGRESS_DELAY=0 \
		scalar clone "file://$(pwd)/to-clone" "$enlistment" 2>stderr &&
	grep "Enumerating objects" stderr >actual &&
	test_line_count = 2 actual &&
	cleanup_clone $enlistment
'

test_expect_success TTY 'progress without tty' '
	enlistment=progress2 &&

	test_config -C to-clone uploadpack.allowfilter true &&
	test_config -C to-clone uploadpack.allowanysha1inwant true &&

	GIT_PROGRESS_DELAY=0 scalar clone "file://$(pwd)/to-clone" "$enlistment" 2>stderr &&
	! grep "Enumerating objects" stderr &&
	! grep "Updating files" stderr &&
	cleanup_clone $enlistment
'

test_done

debug log:

solving 2da8ca6f2bb ...
found 2da8ca6f2bb in https://public-inbox.org/git/pull.1441.v3.git.1673442860379.gitgitgadget@gmail.com/
found dd33d87e9be in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 dd33d87e9be16515276b4b75758ba5eb3a7f8d05	t/t9211-scalar-clone.sh

applying [1/1] https://public-inbox.org/git/pull.1441.v3.git.1673442860379.gitgitgadget@gmail.com/
diff --git a/t/t9211-scalar-clone.sh b/t/t9211-scalar-clone.sh
index dd33d87e9be..2da8ca6f2bb 100755

Checking patch t/t9211-scalar-clone.sh...
Applied patch t/t9211-scalar-clone.sh cleanly.

index at:
100755 2da8ca6f2bba573a74952e12e622c9b5524d659c	t/t9211-scalar-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).