summaryrefslogtreecommitdiff
path: root/t/t1050-large.sh
blob: 4d127f19b78cc76018e316532c905137e9c7ab08 (plain)
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
#!/bin/sh
# Copyright (c) 2011, Google Inc.
 
test_description='adding and checking out large blobs'
 
. ./test-lib.sh
 
test_expect_success setup '
	# clone does not allow us to pass core.bigfilethreshold to
	# new repos, so set core.bigfilethreshold globally
	git config --global core.bigfilethreshold 200k &&
	echo X | dd of=large1 bs=1k seek=2000 &&
	echo X | dd of=large2 bs=1k seek=2000 &&
	echo X | dd of=large3 bs=1k seek=2000 &&
	echo Y | dd of=huge bs=1k seek=2500 &&
	GIT_ALLOC_LIMIT=1500 &&
	export GIT_ALLOC_LIMIT
'
 
test_expect_success 'add a large file or two' '
	git add large1 huge large2 &&
	# make sure we got a single packfile and no loose objects
	bad= count=0 idx= &&
	for p in .git/objects/pack/pack-*.pack
	do
		count=$(( $count + 1 ))
		if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
		then
			continue
		fi
		bad=t
	done &&
	test -z "$bad" &&
	test $count = 1 &&
	cnt=$(git show-index <"$idx" | wc -l) &&
	test $cnt = 2 &&
	for l in .git/objects/??/??????????????????????????????????????
	do
		test -f "$l" || continue
		bad=t
	done &&
	test -z "$bad" &&
 
	# attempt to add another copy of the same
	git add large3 &&
	bad= count=0 &&
	for p in .git/objects/pack/pack-*.pack
	do
		count=$(( $count + 1 ))
		if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
		then
			continue
		fi
		bad=t
	done &&
	test -z "$bad" &&
	test $count = 1
'
 
test_expect_success 'checkout a large file' '
	large1=$(git rev-parse :large1) &&
	git update-index --add --cacheinfo 100644 $large1 another &&
	git checkout another &&
	cmp large1 another ;# this must not be test_cmp
'
 
test_expect_success 'packsize limit' '
	test_create_repo mid &&
	(
		cd mid &&
		git config core.bigfilethreshold 64k &&
		git config pack.packsizelimit 256k &&
 
		# mid1 and mid2 will fit within 256k limit but
		# appending mid3 will bust the limit and will
		# result in a separate packfile.
		test-genrandom "a" $(( 66 * 1024 )) >mid1 &&
		test-genrandom "b" $(( 80 * 1024 )) >mid2 &&
		test-genrandom "c" $(( 128 * 1024 )) >mid3 &&
		git add mid1 mid2 mid3 &&
 
		count=0
		for pi in .git/objects/pack/pack-*.idx
		do
			test -f "$pi" && count=$(( $count + 1 ))
		done &&
		test $count = 2 &&
 
		(
			git hash-object --stdin <mid1
			git hash-object --stdin <mid2
			git hash-object --stdin <mid3
		) |
		sort >expect &&
 
		for pi in .git/objects/pack/pack-*.idx
		do
			git show-index <"$pi"
		done |
		sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
		sort >actual &&
 
		test_cmp expect actual
	)
'
 
test_expect_success 'diff --raw' '
	git commit -q -m initial &&
	echo modified >>large1 &&
	git add large1 &&
	git commit -q -m modified &&
	git diff --raw HEAD^
'
 
test_expect_success 'hash-object' '
	git hash-object large1
'
 
test_expect_success 'cat-file a large file' '
	git cat-file blob :large1 >/dev/null
'
 
test_expect_success 'cat-file a large file from a tag' '
	git tag -m largefile largefiletag :large1 &&
	git cat-file blob largefiletag >/dev/null
'
 
test_expect_success 'git-show a large file' '
	git show :large1 >/dev/null
 
'
 
test_expect_success 'repack' '
	git repack -ad
'
 
test_done