forked from git-lfs/git-lfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-reference-clone.sh
More file actions
executable file
·97 lines (74 loc) · 2.08 KB
/
test-reference-clone.sh
File metadata and controls
executable file
·97 lines (74 loc) · 2.08 KB
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
#!/usr/bin/env bash
. "test/testlib.sh"
assert_same_inode() {
local repo1=$1
local repo2=$2
local oid=$3
if ! uname -s | grep -qE 'CYGWIN|MSYS|MINGW'; then
cfg1=$(cd "$repo1"; git lfs env | grep LocalMediaDir)
f1="${cfg1:14}/${oid:0:2}/${oid:2:2}/$oid"
inode1=$(ls -i $f1 | cut -f1 -d\ )
cfg2=$(cd "$repo2"; git lfs env | grep LocalMediaDir)
f2="${cfg2:14}/${oid:0:2}/${oid:2:2}/$oid"
inode2=$(ls -i $f2 | cut -f1 -d\ )
[ "$inode1" == "$inode2" ]
fi
}
begin_test "clone with reference"
(
set -e
reponame="$(basename "$0" ".sh")"
setup_remote_repo "$reponame"
ref_repo=clone_reference_repo
ref_repo_dir=$TRASHDIR/$ref_repo
clone_repo "$reponame" "$ref_repo"
git lfs track "*.dat"
contents="a"
oid=$(calc_oid "$contents")
printf "$contents" > a.dat
git add a.dat
git add .gitattributes
git commit -m "add a.dat" 2>&1
git push origin master
delete_server_object "$reponame" "$oid"
repo=test_repo
repo_dir=$TRASHDIR/$repo
git clone --reference "$ref_repo_dir/.git" \
"$GITSERVER/$reponame" "$repo_dir" 2> clone.log
if grep -q "Downloading a.dat" clone.log; then
exit 1
fi
cd "$TRASHDIR/$repo"
assert_pointer "master" "a.dat" "$oid" 1
assert_same_inode "$repo_dir" "$ref_repo_dir" "$oid"
)
end_test
begin_test "fetch from clone reference"
(
set -e
reponame="$(basename "$0" ".sh")2"
setup_remote_repo "$reponame"
ref_repo=clone_reference_repo2
ref_repo_dir=$TRASHDIR/$ref_repo
clone_repo "$reponame" "$ref_repo"
repo=test_repo2
repo_dir=$TRASHDIR/$repo
git clone --reference "$ref_repo_dir/.git" \
"$GITSERVER/$reponame" "$repo_dir" 2> clone.log
cd "$ref_repo_dir"
git lfs track "*.dat"
contents="a"
oid=$(calc_oid "$contents")
printf "$contents" > a.dat
git add a.dat
git add .gitattributes
git commit -m "add a.dat" 2>&1
git push origin master
delete_server_object "$reponame" "$oid"
cd "$repo_dir"
GIT_LFS_SKIP_SMUDGE=1 git pull
git lfs pull
assert_pointer "master" "a.dat" "$oid" 1
assert_same_inode "$TRASHDIR/$repo" "$TRASHDIR/$ref_repo" "$oid"
)
end_test