git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
944b7bb28f6d78dfc4efe8e3babbb1f06ea232aa blob 2077 bytes (raw)

 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
 
#!/bin/sh

test_description='basic tests for external object databases'

. ./test-lib.sh

ALT_SOURCE="$PWD/alt-repo/.git"
export ALT_SOURCE
write_script odb-helper <<\EOF
die() {
	printf >&2 "%s\n" "$@"
	exit 1
}
GIT_DIR=$ALT_SOURCE; export GIT_DIR
case "$1" in
init)
	echo "capability=get_git_obj"
	echo "capability=put_raw_obj"
	echo "capability=have"
	;;
have)
	git cat-file --batch-check --batch-all-objects |
	awk '{print $1 " " $3 " " $2}'
	;;
get_git_obj)
	cat "$GIT_DIR"/objects/$(echo $2 | sed 's#..#&/#')
	;;
put_raw_obj)
	sha1="$2"
	size="$3"
	kind="$4"
	written=$(git hash-object -w -t "$kind" --stdin)
	test "$written" = "$sha1" || die "bad sha1 passed '$sha1' vs written '$written'"
	;;
*)
	die "unknown command '$1'"
	;;
esac
EOF
HELPER="\"$PWD\"/odb-helper"

test_expect_success 'setup alternate repo' '
	git init alt-repo &&
	test_commit -C alt-repo one &&
	test_commit -C alt-repo two &&
	alt_head=$(git -C alt-repo rev-parse HEAD)
'

test_expect_success 'alt objects are missing' '
	test_must_fail git log --format=%s $alt_head
'

test_expect_success 'helper can retrieve alt objects' '
	test_config odb.magic.scriptCommand "$HELPER" &&
	cat >expect <<-\EOF &&
	two
	one
	EOF
	git log --format=%s $alt_head >actual &&
	test_cmp expect actual
'

test_expect_success 'helper can add objects to alt repo' '
	hash=$(echo "Hello odb!" | git hash-object -w -t blob --stdin) &&
	test -f .git/objects/$(echo $hash | sed "s#..#&/#") &&
	size=$(git cat-file -s "$hash") &&
	git cat-file blob "$hash" | ./odb-helper put_raw_obj "$hash" "$size" blob &&
	alt_size=$(git -C alt-repo cat-file -s "$hash") &&
	test "$size" -eq "$alt_size"
'

test_expect_success 'commit adds objects to alt repo' '
	test_config odb.magic.scriptCommand "$HELPER" &&
	echo "* odb=magic" >.gitattributes &&
	GIT_NO_EXTERNAL_ODB=1 git add .gitattributes &&
	GIT_NO_EXTERNAL_ODB=1 git commit -m "Add .gitattributes" &&
	test_commit three &&
	hash3=$(git ls-tree HEAD | grep three.t | cut -f1 | cut -d\  -f3) &&
	content=$(git -C alt-repo show "$hash3") &&
	test "$content" = "three"
'

test_done
debug log:

solving 944b7bb28f ...
found 944b7bb28f in https://public-inbox.org/git/20180319133147.15413-36-chriscool@tuxfamily.org/
found f924de870f in https://public-inbox.org/git/20180319133147.15413-20-chriscool@tuxfamily.org/
found 4ccca1e965 in https://public-inbox.org/git/20180319133147.15413-17-chriscool@tuxfamily.org/
found 977fea852d in https://public-inbox.org/git/20180319133147.15413-12-chriscool@tuxfamily.org/
found eaa3688a31 in https://public-inbox.org/git/20180319133147.15413-10-chriscool@tuxfamily.org/

applying [1/5] https://public-inbox.org/git/20180319133147.15413-10-chriscool@tuxfamily.org/
diff --git a/t/t0500-external-odb.sh b/t/t0500-external-odb.sh
new file mode 100755
index 0000000000..eaa3688a31


applying [2/5] https://public-inbox.org/git/20180319133147.15413-12-chriscool@tuxfamily.org/
diff --git a/t/t0500-external-odb.sh b/t/t0500-external-odb.sh
index eaa3688a31..977fea852d 100755


applying [3/5] https://public-inbox.org/git/20180319133147.15413-17-chriscool@tuxfamily.org/
diff --git a/t/t0500-external-odb.sh b/t/t0500-external-odb.sh
index 977fea852d..4ccca1e965 100755


applying [4/5] https://public-inbox.org/git/20180319133147.15413-20-chriscool@tuxfamily.org/
diff --git a/t/t0500-external-odb.sh b/t/t0500-external-odb.sh
index 4ccca1e965..f924de870f 100755


applying [5/5] https://public-inbox.org/git/20180319133147.15413-36-chriscool@tuxfamily.org/
diff --git a/t/t0500-external-odb.sh b/t/t0500-external-odb.sh
index f924de870f..944b7bb28f 100755

Checking patch t/t0500-external-odb.sh...
Applied patch t/t0500-external-odb.sh cleanly.
Checking patch t/t0500-external-odb.sh...
Applied patch t/t0500-external-odb.sh cleanly.
Checking patch t/t0500-external-odb.sh...
Applied patch t/t0500-external-odb.sh cleanly.
Checking patch t/t0500-external-odb.sh...
Applied patch t/t0500-external-odb.sh cleanly.
Checking patch t/t0500-external-odb.sh...
Applied patch t/t0500-external-odb.sh cleanly.

index at:
100755 944b7bb28f6d78dfc4efe8e3babbb1f06ea232aa	t/t0500-external-odb.sh

Code repositories for project(s) associated with this 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).