3 . "$(dirname "$0")/testlib.sh"
5 begin_test "post-checkout"
9 reponame="$(basename "$0" ".sh")"
10 setup_remote_repo "$reponame"
12 clone_repo "$reponame" "$reponame"
14 git lfs track --lockable "*.dat"
15 git lfs track "*.big" # not lockable
16 git add .gitattributes
17 git commit -m "add git attributes"
21 \"CommitDate\":\"$(get_date -10d)\",
23 {\"Filename\":\"file1.dat\",\"Data\":\"file 1 creation\"},
24 {\"Filename\":\"file2.dat\",\"Data\":\"file 2 creation\"}]
27 \"CommitDate\":\"$(get_date -7d)\",
29 {\"Filename\":\"file1.dat\",\"Data\":\"file 1 updated commit 2\"},
30 {\"Filename\":\"file3.big\",\"Data\":\"file 3 creation\"},
31 {\"Filename\":\"file4.big\",\"Data\":\"file 4 creation\"}],
35 \"CommitDate\":\"$(get_date -5d)\",
37 {\"Filename\":\"file2.dat\",\"Data\":\"file 2 updated commit 3\"}]
40 \"CommitDate\":\"$(get_date -3d)\",
41 \"NewBranch\":\"branch2\",
43 {\"Filename\":\"file5.dat\",\"Data\":\"file 5 creation in branch2\"},
44 {\"Filename\":\"file6.big\",\"Data\":\"file 6 creation in branch2\"}]
47 \"CommitDate\":\"$(get_date -1d)\",
49 {\"Filename\":\"file2.dat\",\"Data\":\"file 2 updated in branch2\"},
50 {\"Filename\":\"file3.big\",\"Data\":\"file 3 updated in branch2\"}]
52 ]" | GIT_LFS_SET_LOCKABLE_READONLY=0 lfstest-testutils addcommits
54 # skipped setting read-only above to make bulk load simpler (no read-only issues)
56 git push -u origin master branch2
58 # re-clone the repo so we start fresh
61 clone_repo "$reponame" "$reponame"
65 [ "$(cat file1.dat)" == "file 1 updated commit 2" ]
66 [ "$(cat file2.dat)" == "file 2 updated commit 3" ]
67 [ "$(cat file3.big)" == "file 3 creation" ]
68 [ "$(cat file4.big)" == "file 4 creation" ]
71 # without the post-checkout hook, any changed files would now be writeable
72 refute_file_writeable file1.dat
73 refute_file_writeable file2.dat
74 assert_file_writeable file3.big
75 assert_file_writeable file4.big
81 refute_file_writeable file1.dat
82 refute_file_writeable file2.dat
83 refute_file_writeable file5.dat
84 assert_file_writeable file3.big
85 assert_file_writeable file4.big
86 assert_file_writeable file6.big
88 # Confirm that contents of existing files were updated even though were read-only
89 [ "$(cat file2.dat)" == "file 2 updated in branch2" ]
90 [ "$(cat file3.big)" == "file 3 updated in branch2" ]
93 # restore files inside a branch (causes full scan since no diff)
98 git checkout file1.dat file2.dat file5.dat
99 [ "$(cat file1.dat)" == "file 1 updated commit 2" ]
100 [ "$(cat file2.dat)" == "file 2 updated in branch2" ]
101 [ "$(cat file5.dat)" == "file 5 creation in branch2" ]
102 refute_file_writeable file1.dat
103 refute_file_writeable file2.dat
104 refute_file_writeable file5.dat
106 # now lock files, then remove & restore
107 git lfs lock file1.dat
108 git lfs lock file2.dat
109 assert_file_writeable file1.dat
110 assert_file_writeable file2.dat
112 git checkout file1.dat file2.dat file5.dat
113 assert_file_writeable file1.dat
114 assert_file_writeable file2.dat
115 refute_file_writeable file5.dat