Debian Codegraph @

t/t-zero-len-file.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh"
4
5 reponame="$(basenamescip-shell system . . basename. "$0" ".sh")"
6
7 begin_test "push zero len file"
8 (
9 set -e
10
11 setup_remote_repo "$reponame"
12
13 clone_repo "$reponame" repo
14
15 gitscip-shell system . . git. lfs track "*.dat"
16 touchscip-shell system . . touch. empty.dat
17
18 contents="full"
19 contents_oid=$(calc_oid "$contents")
20 printfscip-shell system . . printf. "%s" "$contents" > full.dat
21 gitscip-shell system . . git. add .gitattributes *.dat
22 gitscip-shell system . . git. commit -m "add files" | teescip-shell system . . tee. commit.log
23
24 # cut from commit output
25 # $ git cat-file -p main
26 # tree 2d67d025fb1f9df9fa349412b4b130e982314e92
27 tree="$(gitscip-shell system . . git. cat-file -p main | cutscip-shell system . . cut. -f 2 -d " " | headscip-shell system . . head. -n 1)"
28
29 # cut from tree output
30 # $ git cat-file -p "$tree"
31 # 100644 blob 1e9f8f7cafb6af3a6f6ddf211fa39c45fccea7ab .gitattributes
32 # 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 empty.dat
33 # 100644 blob c5de5ac7dec1c40bafe60d24da9b498937640332 full.dat
34 emptyblob="$(gitscip-shell system . . git. cat-file -p "$tree" | cutscip-shell system . . cut. -f 3 -d " " | grepscip-shell system . . grep. "empty.dat" | cutscip-shell system . . cut. -f 1 -d$'\t')"
35
36 # look for lfs pointer in git blob
37 [scip-shell system . . `[`. 0 -eq "$(gitscip-shell system . . git. cat-file -p "$emptyblob" | grepscip-shell system . . grep. -c "lfs")" ]
38
39 assert_pointer "main" "full.dat" "$contents_oid" 4
40
41 gitscip-shell system . . git. push origin main | teescip-shell system . . tee. push.log
42 grepscip-shell system . . grep. "Uploading LFS objects: 100% (1/1), 4 B" push.log
43 )
44 end_test
45
46 begin_test "pull zero len file"
47 (
48 set -e
49
50 clone_repo "$reponame" clone
51 rmscip-shell system . . rm. clone.log
52
53 gitscip-shell system . . git. status | grepscip-shell system . . grep. -E "working (directory|tree) clean"
54 lsscip-shell system . . ls. -al
55
56 if [scip-shell system . . `[`. -s "empty.dat" ]; then
57 echoscip-shell system . . echo. "empty.dat has content:"
58 catscip-shell system . . cat. empty.dat
59 exit 1
60 fi
61
62 [scip-shell system . . `[`. "full" = "$(catscip-shell system . . cat. full.dat)" ]
63 )
64 end_test