File: t-malformed-pointers.sh

package info (click to toggle)
git-lfs 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,808 kB
  • sloc: sh: 21,256; makefile: 507; ruby: 417
file content (92 lines) | stat: -rwxr-xr-x 2,311 bytes parent folder | download
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
#!/usr/bin/env bash

. "$(dirname "$0")/testlib.sh"

begin_test "malformed pointers"
(
  set -e

  reponame="malformed-pointers"
  setup_remote_repo "$reponame"
  clone_repo "$reponame" "$reponame"

  git lfs track "*.dat"
  git add .gitattributes
  git commit -m "initial commit"

  lfstest-genrandom --base64 1023 >malformed_small.dat
  lfstest-genrandom --base64 1024 >malformed_exact.dat
  lfstest-genrandom --base64 1025 >malformed_large.dat
  lfstest-genrandom --base64 1048576 >malformed_xxl.dat

  git \
    -c "filter.lfs.process=" \
    -c "filter.lfs.clean=cat" \
    -c "filter.lfs.required=false" \
    add *.dat
  git commit -m "add malformed pointer"

  git push origin main

  pushd .. >/dev/null
    clone_repo "$reponame" "$reponame-assert"

    grep "malformed_small.dat" clone.log
    grep "malformed_exact.dat" clone.log
    grep "malformed_large.dat" clone.log
    grep "malformed_xxl.dat" clone.log

    expected_small="$(cat ../$reponame/malformed_small.dat)"
    expected_exact="$(cat ../$reponame/malformed_exact.dat)"
    expected_large="$(cat ../$reponame/malformed_large.dat)"
    expected_xxl="$(cat ../$reponame/malformed_xxl.dat)"

    actual_small="$(cat malformed_small.dat)"
    actual_exact="$(cat malformed_exact.dat)"
    actual_large="$(cat malformed_large.dat)"
    actual_xxl="$(cat malformed_xxl.dat)"

    [ "$expected_small" = "$actual_small" ]
    [ "$expected_exact" = "$actual_exact" ]
    [ "$expected_large" = "$actual_large" ]
    [ "$expected_xxl" = "$actual_xxl" ]
  popd >/dev/null
)
end_test

begin_test "empty pointers"
(
  set -e

  reponame="empty-pointers"
  setup_remote_repo "$reponame"
  clone_repo "$reponame" "$reponame"

  git lfs track "*.dat"
  git add .gitattributes
  git commit -m "initial commit"

  touch empty.dat

  git \
    -c "filter.lfs.process=" \
    -c "filter.lfs.clean=cat" \
    -c "filter.lfs.required=false" \
    add empty.dat
  git commit -m "add empty pointer"

  [ "0" -eq "$(git cat-file -p :empty.dat | wc -c)" ]
  [ "0" -eq "$(wc -c < empty.dat)" ]

  git push origin main

  pushd .. >/dev/null
    clone_repo "$reponame" "$reponame-assert"

    [ "0" -eq "$(grep -c "empty.dat" clone.log)" ]

    [ "0" -eq "$(git cat-file -p :empty.dat | wc -c)" ]
    [ "0" -eq "$(wc -c < empty.dat)" ]
  popd >/dev/null
)
end_test