3 . "$(dirname "$0")/testlib.sh"
5 begin_test "post-merge"
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"
22 \"CommitDate\":\"$(get_date -10d)\",
24 {\"Filename\":\"file1.dat\",\"Data\":\"file 1 creation\"},
25 {\"Filename\":\"file2.dat\",\"Data\":\"file 2 creation\"}]
28 \"CommitDate\":\"$(get_date -7d)\",
30 {\"Filename\":\"file1.dat\",\"Data\":\"file 1 updated commit 2\"},
31 {\"Filename\":\"file3.big\",\"Data\":\"file 3 creation\"},
32 {\"Filename\":\"file4.big\",\"Data\":\"file 4 creation\"}],
36 \"CommitDate\":\"$(get_date -5d)\",
38 {\"Filename\":\"file2.dat\",\"Data\":\"file 2 updated commit 3\"}]
41 \"CommitDate\":\"$(get_date -3d)\",
42 \"NewBranch\":\"branch2\",
44 {\"Filename\":\"file5.dat\",\"Data\":\"file 5 creation in branch2\"},
45 {\"Filename\":\"file6.big\",\"Data\":\"file 6 creation in branch2\"}]
48 \"CommitDate\":\"$(get_date -1d)\",
50 {\"Filename\":\"file2.dat\",\"Data\":\"file 2 updated in branch2\"},
51 {\"Filename\":\"file3.big\",\"Data\":\"file 3 updated in branch2\"}]
53 ]" | GIT_LFS_SET_LOCKABLE_READONLY=0 lfstest-testutils addcommits
55 # skipped setting read-only above to make bulk load simpler (no read-only issues)
57 git push -u origin master branch2
59 # re-clone the repo so we start fresh
62 clone_repo "$reponame" "$reponame"
66 [ "$(cat file1.dat)" == "file 1 updated commit 2" ]
67 [ "$(cat file2.dat)" == "file 2 updated commit 3" ]
68 [ "$(cat file3.big)" == "file 3 creation" ]
69 [ "$(cat file4.big)" == "file 4 creation" ]
72 # without the post-checkout hook, any changed files would now be writeable
73 refute_file_writeable file1.dat
74 refute_file_writeable file2.dat
75 assert_file_writeable file3.big
76 assert_file_writeable file4.big
78 # merge branch, with readonly option disabled to demonstrate what would happen
79 GIT_LFS_SET_LOCKABLE_READONLY=0 git merge origin/branch2
80 # branch2 had hanges to file2.dat and file5.dat which were lockable
81 # but because we disabled the readonly feature they will be writeable now
82 assert_file_writeable file2.dat
83 assert_file_writeable file5.dat
85 # now let's do it again with the readonly option enabled
86 git reset --hard HEAD^
87 git merge origin/branch2
89 # This time they should be read-only
90 refute_file_writeable file2.dat
91 refute_file_writeable file5.dat
93 # Confirm that contents of existing files were updated even though were read-only
94 [ "$(cat file2.dat)" == "file 2 updated in branch2" ]
95 [ "$(cat file5.dat)" == "file 5 creation in branch2" ]