2015-10-09 15:55:19 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-07-10 18:48:02 +00:00
|
|
|
. "$(dirname "$0")/testlib.sh"
|
2015-10-09 15:55:19 +00:00
|
|
|
|
2015-10-12 13:49:12 +00:00
|
|
|
begin_test "prune unreferenced and old"
|
2015-10-09 15:55:19 +00:00
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
2015-10-12 13:49:12 +00:00
|
|
|
reponame="prune_unref_old"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
2015-10-09 15:55:19 +00:00
|
|
|
|
2015-10-12 13:49:12 +00:00
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
2015-10-09 15:55:19 +00:00
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2015-10-09 15:55:19 +00:00
|
|
|
|
|
|
|
# generate content we'll use
|
|
|
|
content_unreferenced="To delete: unreferenced"
|
|
|
|
content_oldandpushed="To delete: pushed and too old"
|
|
|
|
content_oldandunchanged="Keep: pushed and created a while ago, but still current"
|
|
|
|
oid_unreferenced=$(calc_oid "$content_unreferenced")
|
|
|
|
oid_oldandpushed=$(calc_oid "$content_oldandpushed")
|
|
|
|
oid_oldandunchanged=$(calc_oid "$content_oldandunchanged")
|
2015-10-12 13:49:12 +00:00
|
|
|
content_retain1="Retained content 1"
|
|
|
|
content_retain2="Retained content 2"
|
|
|
|
oid_retain1=$(calc_oid "$content_retain1")
|
|
|
|
oid_retain2=$(calc_oid "$content_retain2")
|
2015-10-09 15:55:19 +00:00
|
|
|
|
2015-10-12 13:49:12 +00:00
|
|
|
# Remember for something to be 'too old' it has to appear on the MINUS side
|
|
|
|
# of the diff outside the prune window, i.e. it's not when it was introduced
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
# but when it disappeared from relevance. That's why changes to old.dat on main
|
2015-10-12 13:49:12 +00:00
|
|
|
# from 7d ago are included even though the commit itself is outside of the window,
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
# that content of old.dat was relevant until it was removed with a commit, inside the window
|
2015-10-12 13:49:12 +00:00
|
|
|
# think of it as windows of relevance that overlap until the content is replaced
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
# we also make sure we commit today on main so that the recent commits measured
|
|
|
|
# from latest commit on main tracks back from there
|
2015-10-09 15:55:19 +00:00
|
|
|
echo "[
|
|
|
|
{
|
2015-10-12 13:49:12 +00:00
|
|
|
\"CommitDate\":\"$(get_date -20d)\",
|
2015-10-09 15:55:19 +00:00
|
|
|
\"Files\":[
|
2015-10-12 13:49:12 +00:00
|
|
|
{\"Filename\":\"old.dat\",\"Size\":${#content_oldandpushed}, \"Data\":\"$content_oldandpushed\"},
|
|
|
|
{\"Filename\":\"stillcurrent.dat\",\"Size\":${#content_oldandunchanged}, \"Data\":\"$content_oldandunchanged\"}]
|
2015-10-09 15:55:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
2015-10-12 13:49:12 +00:00
|
|
|
{\"Filename\":\"old.dat\",\"Size\":${#content_retain1}, \"Data\":\"$content_retain1\"}]
|
2015-10-09 15:55:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -4d)\",
|
2017-03-24 16:59:03 +00:00
|
|
|
\"NewBranch\":\"branch_to_delete\",
|
2015-10-09 15:55:19 +00:00
|
|
|
\"Files\":[
|
2015-10-12 13:49:12 +00:00
|
|
|
{\"Filename\":\"unreferenced.dat\",\"Size\":${#content_unreferenced}, \"Data\":\"$content_unreferenced\"}]
|
2015-10-09 15:55:19 +00:00
|
|
|
},
|
|
|
|
{
|
2020-06-29 16:18:57 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2015-10-09 15:55:19 +00:00
|
|
|
\"Files\":[
|
2015-10-12 13:49:12 +00:00
|
|
|
{\"Filename\":\"old.dat\",\"Size\":${#content_retain2}, \"Data\":\"$content_retain2\"}]
|
2015-10-09 15:55:19 +00:00
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
2015-10-12 13:49:12 +00:00
|
|
|
git branch -D branch_to_delete
|
2015-10-09 15:55:19 +00:00
|
|
|
|
|
|
|
git config lfs.fetchrecentrefsdays 5
|
|
|
|
git config lfs.fetchrecentremoterefs true
|
|
|
|
git config lfs.fetchrecentcommitsdays 3
|
2015-10-14 14:53:36 +00:00
|
|
|
git config lfs.pruneoffsetdays 2
|
2015-10-09 15:55:19 +00:00
|
|
|
|
2015-10-12 13:49:12 +00:00
|
|
|
git lfs prune --dry-run --verbose 2>&1 | tee prune.log
|
|
|
|
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 5 local objects, 3 retained" prune.log
|
|
|
|
grep "prune: 2 files would be pruned" prune.log
|
2015-10-12 13:49:12 +00:00
|
|
|
grep "$oid_oldandpushed" prune.log
|
|
|
|
grep "$oid_unreferenced" prune.log
|
|
|
|
|
|
|
|
assert_local_object "$oid_oldandpushed" "${#content_oldandpushed}"
|
|
|
|
assert_local_object "$oid_unreferenced" "${#content_unreferenced}"
|
|
|
|
git lfs prune
|
|
|
|
refute_local_object "$oid_oldandpushed" "${#content_oldandpushed}"
|
|
|
|
refute_local_object "$oid_unreferenced" "${#content_unreferenced}"
|
2022-04-20 07:27:59 +00:00
|
|
|
assert_local_object "$oid_oldandunchanged" "${#content_oldandunchanged}"
|
2015-10-12 13:49:12 +00:00
|
|
|
assert_local_object "$oid_retain1" "${#content_retain1}"
|
|
|
|
assert_local_object "$oid_retain2" "${#content_retain2}"
|
2015-10-09 15:55:19 +00:00
|
|
|
|
2015-10-12 15:58:26 +00:00
|
|
|
# now only keep AT refs, no recents
|
|
|
|
git config lfs.fetchrecentcommitsdays 0
|
2017-11-28 03:31:32 +00:00
|
|
|
|
2015-10-12 15:58:26 +00:00
|
|
|
git lfs prune --verbose 2>&1 | tee prune.log
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 3 local objects, 2 retained" prune.log
|
2019-08-23 21:01:19 +00:00
|
|
|
grep "prune: Deleting objects: 100% (1/1), done." prune.log
|
2015-10-12 15:58:26 +00:00
|
|
|
grep "$oid_retain1" prune.log
|
|
|
|
refute_local_object "$oid_retain1"
|
|
|
|
assert_local_object "$oid_retain2" "${#content_retain2}"
|
2015-10-09 15:55:19 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2022-04-20 07:27:59 +00:00
|
|
|
begin_test "prune all excluded paths"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_unref_old_exclude"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
|
|
|
|
# generate content we'll use
|
|
|
|
content_oldandexcluded="To delete: pushed and too old and excluded by filter"
|
|
|
|
content_oldandunchanged="Keep: pushed and created a while ago, but still current"
|
|
|
|
content_prevandexcluded="To delete: pushed and in previous commit to HEAD but excluded by filter"
|
2022-04-22 07:14:28 +00:00
|
|
|
content_unreferencedandexcluded="To delete: unreferenced in deleted branch and pushed and excluded by filter"
|
|
|
|
content_includedandexcluded="Keep: pushed and both excluded by filter and included by another path"
|
2022-04-20 07:27:59 +00:00
|
|
|
content_excluded="To delete: pushed and in HEAD but excluded by filter"
|
|
|
|
oid_oldandexcluded=$(calc_oid "$content_oldandexcluded")
|
|
|
|
oid_oldandunchanged=$(calc_oid "$content_oldandunchanged")
|
|
|
|
oid_prevandexcluded=$(calc_oid "$content_prevandexcluded")
|
2022-04-22 07:14:28 +00:00
|
|
|
oid_unreferencedandexcluded=$(calc_oid "$content_unreferencedandexcluded")
|
|
|
|
oid_includedandexcluded=$(calc_oid "$content_includedandexcluded")
|
2022-04-20 07:27:59 +00:00
|
|
|
oid_excluded=$(calc_oid "$content_excluded")
|
|
|
|
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -20d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"foo/oldandexcluded.dat\",\"Size\":${#content_oldandexcluded}, \"Data\":\"$content_oldandexcluded\"},
|
|
|
|
{\"Filename\":\"stillcurrent.dat\",\"Size\":${#content_oldandunchanged}, \"Data\":\"$content_oldandunchanged\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"foo/oldandexcluded.dat\",\"Size\":${#content_prevandexcluded}, \"Data\":\"$content_prevandexcluded\"}]
|
|
|
|
},
|
|
|
|
{
|
2022-04-22 07:14:28 +00:00
|
|
|
\"CommitDate\":\"$(get_date -4d)\",
|
|
|
|
\"NewBranch\":\"branch_to_delete\",
|
2022-04-20 07:27:59 +00:00
|
|
|
\"Files\":[
|
2022-04-22 07:14:28 +00:00
|
|
|
{\"Filename\":\"unreferenced.dat\",\"Size\":${#content_unreferencedandexcluded}, \"Data\":\"$content_unreferencedandexcluded\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"ParentBranches\":[\"main\"],
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"foo/unreferencedandexcluded.dat\",\"Size\":${#content_unreferencedandexcluded}, \"Data\":\"$content_unreferencedandexcluded\"},
|
|
|
|
{\"Filename\":\"foo/includedandexcluded.dat\",\"Size\":${#content_includedandexcluded}, \"Data\":\"$content_includedandexcluded\"},
|
|
|
|
{\"Filename\":\"included.dat\",\"Size\":${#content_includedandexcluded}, \"Data\":\"$content_includedandexcluded\"},
|
2022-04-20 07:27:59 +00:00
|
|
|
{\"Filename\":\"foo/oldandexcluded.dat\",\"Size\":${#content_excluded}, \"Data\":\"$content_excluded\"}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
git push origin main
|
2022-04-22 07:14:28 +00:00
|
|
|
git branch -D branch_to_delete
|
2022-04-20 07:27:59 +00:00
|
|
|
|
|
|
|
git config lfs.fetchrecentrefsdays 5
|
|
|
|
git config lfs.fetchrecentremoterefs true
|
|
|
|
git config lfs.fetchrecentcommitsdays 3
|
|
|
|
git config lfs.pruneoffsetdays 2
|
|
|
|
|
|
|
|
# We need to prevent MSYS from rewriting /foo into a Windows path.
|
commands,t: gitignore matching for fetch filters
The "lfs.fetchinclude" and "lfs.fetchexclude" Git configuration
options, if set, are used to control the action of a number of Git
LFS commands. Since PR #4556, the "git lfs clone", "git lfs fetch",
and "git lfs pull" commands have strictly applied gitignore(5)-style
matching rules to these configuration options.
However, other commands including "git lfs filter-process" and
"git lfs smudge" now apply gitattributes(5)-style matching
rules to these same configuration options, leading to confusion.
We therefore revise all remaining uses of these configuration
options to also use gitignore-style matching rules.
We also add new tests for the "git lfs filter-process" and "git lfs
fsck" commands and adjust or expand existing tests for the "git lfs
prune" and "git lfs smudge" commands in order to confirm that
gitignore-style matching is used for all of them. These new and
updated tests fail if gitattributes-style matching is used instead.
(Note that the "git lfs migrate" command does not require any changes
because it does not read the "lfs.fetch*" configuration options.
Instead, it supplies a "false" value for the "useFetchOptions" flag
to the determineIncludeExcludePaths() function, so any "lfs.fetch*"
configuration values are ignored. This is significant because
"git lfs migrate" deliberately uses gitattributes-style matching
for any path patterns supplied via its -I/-X command-line arguments,
unlike all other commands that accept -I/-X arguments as overrides
for the "lfs.fetch*" configuration options.)
2022-04-18 07:24:53 +00:00
|
|
|
MSYS_NO_PATHCONV=1 git config "lfs.fetchexclude" "/foo"
|
2022-04-20 07:27:59 +00:00
|
|
|
|
|
|
|
git lfs prune --dry-run --verbose 2>&1 | tee prune.log
|
|
|
|
|
2022-04-22 07:14:28 +00:00
|
|
|
grep "prune: 6 local objects, 2 retained" prune.log
|
|
|
|
grep "prune: 4 files would be pruned" prune.log
|
2022-04-20 07:27:59 +00:00
|
|
|
grep "$oid_oldandexcluded" prune.log
|
|
|
|
grep "$oid_prevandexcluded" prune.log
|
2022-04-22 07:14:28 +00:00
|
|
|
grep "$oid_unreferencedandexcluded" prune.log
|
2022-04-20 07:27:59 +00:00
|
|
|
grep "$oid_excluded" prune.log
|
|
|
|
|
2022-04-22 07:14:28 +00:00
|
|
|
assert_local_object "$oid_oldandexcluded" "${#content_oldandexcluded}"
|
|
|
|
assert_local_object "$oid_prevandexcluded" "${#content_prevandexcluded}"
|
|
|
|
assert_local_object "$oid_unreferencedandexcluded" "${#content_unreferencedandexcluded}"
|
|
|
|
assert_local_object "$oid_excluded" "${#content_excluded}"
|
2022-04-20 07:27:59 +00:00
|
|
|
git lfs prune
|
|
|
|
refute_local_object "$oid_oldandexcluded" "${#content_oldandexcluded}"
|
|
|
|
assert_local_object "$oid_oldandunchanged" "${#content_oldandunchanged}"
|
|
|
|
refute_local_object "$oid_prevandexcluded" "${#content_prevandexcluded}"
|
2022-04-22 07:14:28 +00:00
|
|
|
refute_local_object "$oid_unreferencedandexcluded" "${#content_unreferencedandexcluded}"
|
|
|
|
assert_local_object "$oid_includedandexcluded" "${#content_includedandexcluded}"
|
2022-04-20 07:27:59 +00:00
|
|
|
refute_local_object "$oid_excluded" "${#content_excluded}"
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2015-10-12 15:59:38 +00:00
|
|
|
begin_test "prune keep unpushed"
|
2015-10-09 15:55:19 +00:00
|
|
|
(
|
2015-10-12 15:59:38 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# need to set up many commits on each branch with old data so that would
|
|
|
|
# get deleted if it were not for unpushed status (heads would never be pruned but old changes would)
|
|
|
|
reponame="prune_keep_unpushed"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2015-10-12 15:59:38 +00:00
|
|
|
|
|
|
|
content_keepunpushedhead1="Keep: unpushed HEAD 1"
|
|
|
|
content_keepunpushedhead2="Keep: unpushed HEAD 2"
|
|
|
|
content_keepunpushedhead3="Keep: unpushed HEAD 3"
|
|
|
|
content_keepunpushedbranch1="Keep: unpushed second branch 1"
|
|
|
|
content_keepunpushedbranch2="Keep: unpushed second branch 2"
|
|
|
|
content_keepunpushedbranch3="Keep: unpushed second branch 3"
|
2022-04-24 23:31:17 +00:00
|
|
|
content_keepunpushedandexcludedbranch1="Keep: unpushed second branch 1 excluded by filter"
|
|
|
|
content_keepunpushedandexcludedbranch2="Keep: unpushed second branch 2 excluded by filter"
|
|
|
|
content_keepunpushedandexcludedbranch3="Keep: unpushed second branch 3 excluded by filter"
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
content_keepunpushedtag1="Keep: unpushed tag only 1"
|
|
|
|
content_keepunpushedtag2="Keep: unpushed tag only 2"
|
|
|
|
content_keepunpushedtag3="Keep: unpushed tag only 3"
|
2015-10-12 15:59:38 +00:00
|
|
|
oid_keepunpushedhead1=$(calc_oid "$content_keepunpushedhead1")
|
|
|
|
oid_keepunpushedhead2=$(calc_oid "$content_keepunpushedhead2")
|
|
|
|
oid_keepunpushedhead3=$(calc_oid "$content_keepunpushedhead3")
|
|
|
|
oid_keepunpushedbranch1=$(calc_oid "$content_keepunpushedbranch1")
|
|
|
|
oid_keepunpushedbranch2=$(calc_oid "$content_keepunpushedbranch2")
|
|
|
|
oid_keepunpushedbranch3=$(calc_oid "$content_keepunpushedbranch3")
|
2022-04-24 23:31:17 +00:00
|
|
|
oid_keepunpushedandexcludedbranch1=$(calc_oid "$content_keepunpushedandexcludedbranch1")
|
|
|
|
oid_keepunpushedandexcludedbranch2=$(calc_oid "$content_keepunpushedandexcludedbranch2")
|
|
|
|
oid_keepunpushedandexcludedbranch3=$(calc_oid "$content_keepunpushedandexcludedbranch3")
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
oid_keepunpushedtag1=$(calc_oid "$content_keepunpushedtag1")
|
|
|
|
oid_keepunpushedtag2=$(calc_oid "$content_keepunpushedtag2")
|
|
|
|
oid_keepunpushedtag3=$(calc_oid "$content_keepunpushedtag3")
|
2015-10-12 15:59:38 +00:00
|
|
|
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -40d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keepunpushedhead1}, \"Data\":\"$content_keepunpushedhead1\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -31d)\",
|
2020-06-29 16:18:57 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2017-03-24 16:59:03 +00:00
|
|
|
\"NewBranch\":\"branch_unpushed\",
|
2015-10-12 15:59:38 +00:00
|
|
|
\"Files\":[
|
2022-04-24 23:31:17 +00:00
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keepunpushedbranch1}, \"Data\":\"$content_keepunpushedbranch1\"},
|
|
|
|
{\"Filename\":\"foo/file.dat\",\"Size\":${#content_keepunpushedandexcludedbranch1}, \"Data\":\"$content_keepunpushedandexcludedbranch1\"}]
|
2015-10-12 15:59:38 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -16d)\",
|
|
|
|
\"Files\":[
|
2022-04-24 23:31:17 +00:00
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keepunpushedbranch2}, \"Data\":\"$content_keepunpushedbranch2\"},
|
|
|
|
{\"Filename\":\"foo/file.dat\",\"Size\":${#content_keepunpushedandexcludedbranch2}, \"Data\":\"$content_keepunpushedandexcludedbranch2\"}]
|
2015-10-12 15:59:38 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Files\":[
|
2022-04-24 23:31:17 +00:00
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keepunpushedbranch3}, \"Data\":\"$content_keepunpushedbranch3\"},
|
|
|
|
{\"Filename\":\"foo/file.dat\",\"Size\":${#content_keepunpushedandexcludedbranch3}, \"Data\":\"$content_keepunpushedandexcludedbranch3\"}]
|
2015-10-12 15:59:38 +00:00
|
|
|
},
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -31d)\",
|
|
|
|
\"ParentBranches\":[\"main\"],
|
|
|
|
\"NewBranch\":\"branch_unpushed_tagged_only\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":${#content_keepunpushedtag1}, \"Data\":\"$content_keepunpushedtag1\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -16d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":${#content_keepunpushedtag2}, \"Data\":\"$content_keepunpushedtag2\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Tags\":[\"tag_unpushed\"],
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file2.dat\",\"Size\":${#content_keepunpushedtag3}, \"Data\":\"$content_keepunpushedtag3\"}]
|
|
|
|
},
|
2015-10-12 15:59:38 +00:00
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -21d)\",
|
2020-06-29 16:18:57 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2015-10-12 15:59:38 +00:00
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keepunpushedhead2}, \"Data\":\"$content_keepunpushedhead2\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -0d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keepunpushedhead3}, \"Data\":\"$content_keepunpushedhead3\"}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
git config lfs.fetchrecentrefsdays 5
|
|
|
|
git config lfs.fetchrecentremoterefs true
|
|
|
|
git config lfs.fetchrecentcommitsdays 0 # only keep AT refs, no recents
|
2015-10-14 14:53:36 +00:00
|
|
|
git config lfs.pruneoffsetdays 2
|
2015-10-12 15:59:38 +00:00
|
|
|
|
2022-04-24 23:31:17 +00:00
|
|
|
# We need to prevent MSYS from rewriting /foo into a Windows path.
|
commands,t: gitignore matching for fetch filters
The "lfs.fetchinclude" and "lfs.fetchexclude" Git configuration
options, if set, are used to control the action of a number of Git
LFS commands. Since PR #4556, the "git lfs clone", "git lfs fetch",
and "git lfs pull" commands have strictly applied gitignore(5)-style
matching rules to these configuration options.
However, other commands including "git lfs filter-process" and
"git lfs smudge" now apply gitattributes(5)-style matching
rules to these same configuration options, leading to confusion.
We therefore revise all remaining uses of these configuration
options to also use gitignore-style matching rules.
We also add new tests for the "git lfs filter-process" and "git lfs
fsck" commands and adjust or expand existing tests for the "git lfs
prune" and "git lfs smudge" commands in order to confirm that
gitignore-style matching is used for all of them. These new and
updated tests fail if gitattributes-style matching is used instead.
(Note that the "git lfs migrate" command does not require any changes
because it does not read the "lfs.fetch*" configuration options.
Instead, it supplies a "false" value for the "useFetchOptions" flag
to the determineIncludeExcludePaths() function, so any "lfs.fetch*"
configuration values are ignored. This is significant because
"git lfs migrate" deliberately uses gitattributes-style matching
for any path patterns supplied via its -I/-X command-line arguments,
unlike all other commands that accept -I/-X arguments as overrides
for the "lfs.fetch*" configuration options.)
2022-04-18 07:24:53 +00:00
|
|
|
MSYS_NO_PATHCONV=1 git config "lfs.fetchexclude" "/foo"
|
2022-04-24 23:31:17 +00:00
|
|
|
|
2021-08-18 01:31:41 +00:00
|
|
|
# force color codes in git diff meta-information
|
|
|
|
git config color.diff always
|
|
|
|
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
git branch -D branch_unpushed_tagged_only
|
|
|
|
|
2017-11-28 03:31:32 +00:00
|
|
|
git lfs prune
|
2015-10-12 15:59:38 +00:00
|
|
|
|
2022-04-24 23:03:39 +00:00
|
|
|
# Now push main and show that only older versions on main will be removed.
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
2015-10-12 15:59:38 +00:00
|
|
|
|
|
|
|
git lfs prune --verbose 2>&1 | tee prune.log
|
2022-04-24 23:31:17 +00:00
|
|
|
grep "prune: 12 local objects, 10 retained" prune.log
|
2019-08-23 21:01:19 +00:00
|
|
|
grep "prune: Deleting objects: 100% (2/2), done." prune.log
|
2015-10-12 15:59:38 +00:00
|
|
|
grep "$oid_keepunpushedhead1" prune.log
|
|
|
|
grep "$oid_keepunpushedhead2" prune.log
|
|
|
|
refute_local_object "$oid_keepunpushedhead1"
|
|
|
|
refute_local_object "$oid_keepunpushedhead2"
|
|
|
|
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
# Merge the unpushed branch and tag, delete them, and then push main.
|
2022-04-24 23:03:39 +00:00
|
|
|
# Resolve conflicts by taking other branch.
|
2015-10-12 16:30:21 +00:00
|
|
|
git merge -Xtheirs branch_unpushed
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
git merge tag_unpushed
|
2015-10-12 16:30:21 +00:00
|
|
|
git branch -D branch_unpushed
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
git tag -d tag_unpushed
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
2015-10-12 16:30:21 +00:00
|
|
|
|
2022-04-24 23:03:39 +00:00
|
|
|
# Now make sure we purged all the intermediate commits but also make sure
|
|
|
|
# they are on the remote.
|
2015-10-12 16:30:21 +00:00
|
|
|
git lfs prune --verbose 2>&1 | tee prune.log
|
2022-04-24 23:31:17 +00:00
|
|
|
grep "prune: 10 local objects, 2 retained" prune.log
|
|
|
|
grep "prune: Deleting objects: 100% (8/8), done." prune.log
|
2015-10-12 16:30:21 +00:00
|
|
|
grep "$oid_keepunpushedbranch1" prune.log
|
|
|
|
grep "$oid_keepunpushedbranch2" prune.log
|
2022-04-24 23:31:17 +00:00
|
|
|
grep "$oid_keepunpushedandexcludedbranch1" prune.log
|
|
|
|
grep "$oid_keepunpushedandexcludedbranch2" prune.log
|
|
|
|
# This is in the new HEAD and would be retained except that it is also
|
|
|
|
# excluded by the filter and has been pushed, so it should have been purged.
|
|
|
|
grep "$oid_keepunpushedandexcludedbranch3" prune.log
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
grep "$oid_keepunpushedtag1" prune.log
|
|
|
|
grep "$oid_keepunpushedtag2" prune.log
|
2015-10-14 11:51:30 +00:00
|
|
|
grep "$oid_keepunpushedhead3" prune.log
|
2015-10-12 16:30:21 +00:00
|
|
|
refute_local_object "$oid_keepunpushedbranch1"
|
|
|
|
refute_local_object "$oid_keepunpushedbranch2"
|
2022-04-24 23:31:17 +00:00
|
|
|
refute_local_object "$oid_keepunpushedandexcludedbranch1"
|
|
|
|
refute_local_object "$oid_keepunpushedandexcludedbranch2"
|
|
|
|
# This is in the new HEAD and would be retained except that it is also
|
|
|
|
# excluded by the filter and has been pushed, so it should have been purged.
|
|
|
|
refute_local_object "$oid_keepunpushedandexcludedbranch3"
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
refute_local_object "$oid_keepunpushedtag1"
|
|
|
|
refute_local_object "$oid_keepunpushedtag2"
|
2022-04-24 23:03:39 +00:00
|
|
|
# We used -Xtheirs when merging the branch so the old HEAD is now obsolete.
|
2015-10-12 16:30:21 +00:00
|
|
|
refute_local_object "$oid_keepunpushedhead3"
|
|
|
|
assert_server_object "remote_$reponame" "$oid_keepunpushedbranch1"
|
|
|
|
assert_server_object "remote_$reponame" "$oid_keepunpushedbranch2"
|
2022-04-24 23:31:17 +00:00
|
|
|
assert_server_object "remote_$reponame" "$oid_keepunpushedandexcludedbranch1"
|
|
|
|
assert_server_object "remote_$reponame" "$oid_keepunpushedandexcludedbranch2"
|
|
|
|
assert_server_object "remote_$reponame" "$oid_keepunpushedandexcludedbranch3"
|
t/t-prune.sh: add tag check to unpushed test
In PR #742 the "git lfs prune" command was introduced along with
accompanying tests, one of which is the "prune keep unpushed"
test that checks whether Git LFS objects referenced by not-yet-
pushed commits are always retained by "git lfs prune".
In commit 978899e3b538bdd7df0873c2b50d229d5748605d of that PR
the initial version of the "prune" tests included some fixture
data with commits that were referenced via a tag only, not via
a branch ref. However, the test never confirmed that the Git LFS
objects in these commits were retained by the "prune" command.
This initial test was then refactored into several tests in
commits 03b85e08acf727428c4e9c0d805f5a8a3da501e7 and
58dfa23c9e87bd638eb2bd7b4c8e208eab8031e7, including the "prune
keep unpushed" one, and in the process two lines were left
which referred to the fixture data ("oid_keepunpushedtagged1"
and "oid_keepunpushedtagged2") but this data was otherwise
dropped from the test, and no tag check was implemented.
We therefore re-introduce some fixture data for this test
which simulates a tag that points to a commit from a deleted
branch, so that the tag is the only reference to this commit
and its ancestors. We then ensure that "git lfs prune" retains
all the Git LFS objects from these commits, even if they
are not recent, when they have not been pushed. Once they are
pushed, we then confirm that only the object in the tagged commit
is retained (because it is a referenced by a recent ref).
We also update a comment in the "prune unreferenced and old"
test which refers to a filename in its fixture data that
corresponds to how it was originally defined in commit
978899e3b538bdd7df0873c2b50d229d5748605d, but which was
subsequently changed (at the same time the comment was added)
in commit 03b85e08acf727428c4e9c0d805f5a8a3da501e7.
2022-04-24 23:14:58 +00:00
|
|
|
assert_server_object "remote_$reponame" "$oid_keepunpushedtag1"
|
|
|
|
assert_server_object "remote_$reponame" "$oid_keepunpushedtag2"
|
2015-10-14 11:51:30 +00:00
|
|
|
assert_server_object "remote_$reponame" "$oid_keepunpushedhead3"
|
2015-10-09 15:55:19 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2015-10-14 14:54:09 +00:00
|
|
|
begin_test "prune keep recent"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_recent"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2015-10-14 14:54:09 +00:00
|
|
|
|
|
|
|
content_keephead="Keep: HEAD"
|
|
|
|
content_keeprecentbranch1tip="Keep: Recent branch 1 tip"
|
|
|
|
content_keeprecentbranch2tip="Keep: Recent branch 2 tip"
|
|
|
|
content_keeprecentcommithead="Keep: Recent commit on HEAD"
|
|
|
|
content_keeprecentcommitbranch1="Keep: Recent commit on recent branch 1"
|
|
|
|
content_keeprecentcommitbranch2="Keep: Recent commit on recent branch 2"
|
|
|
|
content_prunecommitoldbranch1="Prune: old commit on old branch"
|
|
|
|
content_prunecommitoldbranch2="Prune: old branch tip"
|
|
|
|
content_prunecommitbranch1="Prune: old commit on recent branch 1"
|
|
|
|
content_prunecommitbranch2="Prune: old commit on recent branch 2"
|
|
|
|
content_prunecommithead="Prune: old commit on HEAD"
|
|
|
|
oid_keephead=$(calc_oid "$content_keephead")
|
|
|
|
oid_keeprecentbranch1tip=$(calc_oid "$content_keeprecentbranch1tip")
|
|
|
|
oid_keeprecentbranch2tip=$(calc_oid "$content_keeprecentbranch2tip")
|
|
|
|
oid_keeprecentcommithead=$(calc_oid "$content_keeprecentcommithead")
|
|
|
|
oid_keeprecentcommitbranch1=$(calc_oid "$content_keeprecentcommitbranch1")
|
|
|
|
oid_keeprecentcommitbranch2=$(calc_oid "$content_keeprecentcommitbranch2")
|
|
|
|
oid_prunecommitoldbranch=$(calc_oid "$content_prunecommitoldbranch1")
|
|
|
|
oid_prunecommitoldbranch2=$(calc_oid "$content_prunecommitoldbranch2")
|
|
|
|
oid_prunecommitbranch1=$(calc_oid "$content_prunecommitbranch1")
|
|
|
|
oid_prunecommitbranch2=$(calc_oid "$content_prunecommitbranch2")
|
|
|
|
oid_prunecommithead=$(calc_oid "$content_prunecommithead")
|
|
|
|
|
2022-01-05 06:49:08 +00:00
|
|
|
# use a single file so each commit supersedes the last, if different files
|
2015-10-14 14:54:09 +00:00
|
|
|
# then history becomes harder to track
|
|
|
|
# Also note that when considering 'recent' when editing a single file, it means
|
|
|
|
# that the snapshot state overlapped; so the latest commit *before* the day
|
|
|
|
# that you're looking at, not just the commits on/after.
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -50d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_prunecommithead}, \"Data\":\"$content_prunecommithead\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -30d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keeprecentcommithead}, \"Data\":\"$content_keeprecentcommithead\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -8d)\",
|
2017-03-24 16:59:03 +00:00
|
|
|
\"NewBranch\":\"branch_old\",
|
2015-10-14 14:54:09 +00:00
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_prunecommitoldbranch1}, \"Data\":\"$content_prunecommitoldbranch1\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_prunecommitoldbranch2}, \"Data\":\"$content_prunecommitoldbranch2\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -9d)\",
|
2020-06-29 16:18:57 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2017-03-24 16:59:03 +00:00
|
|
|
\"NewBranch\":\"branch1\",
|
2015-10-14 14:54:09 +00:00
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_prunecommitbranch1}, \"Data\":\"$content_prunecommitbranch1\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -8d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keeprecentcommitbranch1}, \"Data\":\"$content_keeprecentcommitbranch1\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -5d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keeprecentbranch1tip}, \"Data\":\"$content_keeprecentbranch1tip\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -17d)\",
|
2020-06-29 16:18:57 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2017-03-24 16:59:03 +00:00
|
|
|
\"NewBranch\":\"branch2\",
|
2015-10-14 14:54:09 +00:00
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_prunecommitbranch2}, \"Data\":\"$content_prunecommitbranch2\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -10d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keeprecentcommitbranch2}, \"Data\":\"$content_keeprecentcommitbranch2\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keeprecentbranch2tip}, \"Data\":\"$content_keeprecentbranch2tip\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -1d)\",
|
2020-06-29 16:18:57 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2015-10-14 14:54:09 +00:00
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_keephead}, \"Data\":\"$content_keephead\"}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
# keep refs for 6 days & any prev commit that overlaps 2 days before tip (recent + offset)
|
|
|
|
git config lfs.fetchrecentrefsdays 5
|
|
|
|
git config lfs.fetchrecentremoterefs true
|
2017-03-24 16:59:03 +00:00
|
|
|
git config lfs.fetchrecentcommitsdays 1
|
2015-10-14 14:54:09 +00:00
|
|
|
git config lfs.pruneoffsetdays 1
|
|
|
|
|
2021-08-18 01:31:41 +00:00
|
|
|
# force color codes in git diff meta-information
|
|
|
|
git config color.diff always
|
|
|
|
|
2015-10-14 14:54:09 +00:00
|
|
|
# push everything so that's not a reason to retain
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main:main branch_old:branch_old branch1:branch1 branch2:branch2
|
2015-10-14 14:54:09 +00:00
|
|
|
|
|
|
|
git lfs prune --verbose 2>&1 | tee prune.log
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 11 local objects, 6 retained, done." prune.log
|
2019-08-23 21:01:19 +00:00
|
|
|
grep "prune: Deleting objects: 100% (5/5), done." prune.log
|
2015-10-14 14:54:09 +00:00
|
|
|
grep "$oid_prunecommitoldbranch" prune.log
|
|
|
|
grep "$oid_prunecommitoldbranch2" prune.log
|
|
|
|
grep "$oid_prunecommitbranch1" prune.log
|
|
|
|
grep "$oid_prunecommitbranch2" prune.log
|
|
|
|
grep "$oid_prunecommithead" prune.log
|
|
|
|
|
|
|
|
refute_local_object "$oid_prunecommitoldbranch"
|
|
|
|
refute_local_object "$oid_prunecommitoldbranch2"
|
|
|
|
refute_local_object "$oid_prunecommitbranch1"
|
|
|
|
refute_local_object "$oid_prunecommitbranch2"
|
|
|
|
refute_local_object "$oid_prunecommithead"
|
|
|
|
assert_local_object "$oid_keephead" "${#content_keephead}"
|
|
|
|
assert_local_object "$oid_keeprecentbranch1tip" "${#content_keeprecentbranch1tip}"
|
|
|
|
assert_local_object "$oid_keeprecentbranch2tip" "${#content_keeprecentbranch2tip}"
|
|
|
|
assert_local_object "$oid_keeprecentcommithead" "${#content_keeprecentcommithead}"
|
|
|
|
assert_local_object "$oid_keeprecentcommitbranch1" "${#content_keeprecentcommitbranch1}"
|
|
|
|
assert_local_object "$oid_keeprecentcommitbranch2" "${#content_keeprecentcommitbranch2}"
|
|
|
|
|
2015-10-14 14:58:12 +00:00
|
|
|
# now don't include any recent commits in fetch & hence don't retain
|
|
|
|
# still retain tips of branches
|
|
|
|
git config lfs.fetchrecentcommitsdays 0
|
|
|
|
git lfs prune --verbose 2>&1 | tee prune.log
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 6 local objects, 3 retained, done." prune.log
|
2019-08-23 21:01:19 +00:00
|
|
|
grep "prune: Deleting objects: 100% (3/3), done." prune.log
|
2015-10-14 14:58:12 +00:00
|
|
|
assert_local_object "$oid_keephead" "${#content_keephead}"
|
|
|
|
assert_local_object "$oid_keeprecentbranch1tip" "${#content_keeprecentbranch1tip}"
|
|
|
|
assert_local_object "$oid_keeprecentbranch2tip" "${#content_keeprecentbranch2tip}"
|
|
|
|
refute_local_object "$oid_keeprecentcommithead"
|
|
|
|
refute_local_object "$oid_keeprecentcommitbranch1"
|
|
|
|
refute_local_object "$oid_keeprecentcommitbranch2"
|
|
|
|
|
|
|
|
# now don't include any recent refs at all, only keep HEAD
|
|
|
|
git config lfs.fetchrecentrefsdays 0
|
|
|
|
git lfs prune --verbose 2>&1 | tee prune.log
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 3 local objects, 1 retained, done." prune.log
|
2019-08-23 21:01:19 +00:00
|
|
|
grep "prune: Deleting objects: 100% (2/2), done." prune.log
|
2015-10-14 14:58:12 +00:00
|
|
|
assert_local_object "$oid_keephead" "${#content_keephead}"
|
|
|
|
refute_local_object "$oid_keeprecentbranch1tip"
|
|
|
|
refute_local_object "$oid_keeprecentbranch2tip"
|
2015-10-14 14:54:09 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2015-10-15 13:33:46 +00:00
|
|
|
begin_test "prune remote tests"
|
2015-10-09 15:55:19 +00:00
|
|
|
(
|
2015-10-15 09:58:34 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_no_or_nonorigin_remote"
|
|
|
|
git init "$reponame"
|
|
|
|
cd "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2015-10-15 09:58:34 +00:00
|
|
|
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -50d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":30}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -40d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":28}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -35d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":37}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -25d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":42}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
# set no recents so max ability to prune normally
|
|
|
|
git config lfs.fetchrecentrefsdays 0
|
|
|
|
git config lfs.fetchrecentremoterefs true
|
2017-03-24 16:59:03 +00:00
|
|
|
git config lfs.fetchrecentcommitsdays 0
|
2015-10-15 09:58:34 +00:00
|
|
|
git config lfs.pruneoffsetdays 1
|
|
|
|
|
2015-10-15 13:33:46 +00:00
|
|
|
# can never prune with no remote
|
2015-10-15 09:58:34 +00:00
|
|
|
git lfs prune --verbose 2>&1 | tee prune.log
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 4 local objects, 4 retained, done." prune.log
|
2015-10-15 09:58:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
# also make sure nothing is pruned when remote is not origin
|
|
|
|
# create 2 remotes, neither of which is called origin & push to both
|
|
|
|
setup_remote_repo "remote1_$reponame"
|
|
|
|
setup_remote_repo "remote2_$reponame"
|
|
|
|
cd "$TRASHDIR/$reponame"
|
|
|
|
git remote add not_origin "$GITSERVER/remote1_$reponame"
|
2020-06-29 16:18:57 +00:00
|
|
|
git push not_origin main
|
2015-10-15 09:58:34 +00:00
|
|
|
|
|
|
|
git lfs prune --verbose 2>&1 | tee prune.log
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 4 local objects, 4 retained, done." prune.log
|
2015-10-15 09:58:34 +00:00
|
|
|
|
|
|
|
# now set the prune remote to be not_origin, should now prune
|
2015-10-15 13:33:46 +00:00
|
|
|
# do a dry run so we can also verify
|
2015-10-15 09:58:34 +00:00
|
|
|
git config lfs.pruneremotetocheck not_origin
|
|
|
|
|
2015-10-15 13:33:46 +00:00
|
|
|
git lfs prune --verbose --dry-run 2>&1 | tee prune.log
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 4 local objects, 1 retained, done." prune.log
|
|
|
|
grep "prune: 3 files would be pruned" prune.log
|
2015-10-09 15:55:19 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2015-10-15 09:58:34 +00:00
|
|
|
begin_test "prune verify"
|
2015-10-09 15:55:19 +00:00
|
|
|
(
|
2015-10-15 13:43:11 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_verify"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2015-10-15 13:43:11 +00:00
|
|
|
|
|
|
|
content_head="HEAD content"
|
|
|
|
content_commit3="Content for commit 3 (prune)"
|
|
|
|
content_commit2_failverify="Content for commit 2 (prune - fail verify)"
|
|
|
|
content_commit1="Content for commit 1 (prune)"
|
|
|
|
oid_head=$(calc_oid "$content_head")
|
|
|
|
oid_commit3=$(calc_oid "$content_commit3")
|
|
|
|
oid_commit2_failverify=$(calc_oid "$content_commit2_failverify")
|
|
|
|
oid_commit1=$(calc_oid "$content_commit1")
|
|
|
|
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -50d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_commit1}, \"Data\":\"$content_commit1\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -40d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_commit2_failverify}, \"Data\":\"$content_commit2_failverify\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -35d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_commit3}, \"Data\":\"$content_commit3\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -25d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_head}, \"Data\":\"$content_head\"}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
# push all so no unpushed reason to not prune
|
2020-06-29 16:18:57 +00:00
|
|
|
git push origin main
|
2015-10-15 13:43:11 +00:00
|
|
|
|
|
|
|
# set no recents so max ability to prune normally
|
|
|
|
git config lfs.fetchrecentrefsdays 0
|
|
|
|
git config lfs.fetchrecentremoterefs true
|
2017-03-24 16:59:03 +00:00
|
|
|
git config lfs.fetchrecentcommitsdays 0
|
2015-10-15 13:43:11 +00:00
|
|
|
git config lfs.pruneoffsetdays 1
|
|
|
|
|
|
|
|
# confirm that it would prune with verify when no issues
|
|
|
|
git lfs prune --dry-run --verify-remote --verbose 2>&1 | tee prune.log
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 4 local objects, 1 retained, 3 verified with remote, done." prune.log
|
|
|
|
grep "prune: 3 files would be pruned" prune.log
|
2015-10-15 13:43:11 +00:00
|
|
|
grep "$oid_commit3" prune.log
|
|
|
|
grep "$oid_commit2_failverify" prune.log
|
|
|
|
grep "$oid_commit1" prune.log
|
|
|
|
|
|
|
|
# delete one file on the server to make the verify fail
|
|
|
|
delete_server_object "remote_$reponame" "$oid_commit2_failverify"
|
|
|
|
# this should now fail
|
|
|
|
git lfs prune --verify-remote 2>&1 | tee prune.log
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 4 local objects, 1 retained, 2 verified with remote, done." prune.log
|
2015-10-15 13:43:11 +00:00
|
|
|
grep "missing on remote:" prune.log
|
|
|
|
grep "$oid_commit2_failverify" prune.log
|
|
|
|
# Nothing should have been deleted
|
|
|
|
assert_local_object "$oid_commit1" "${#content_commit1}"
|
|
|
|
assert_local_object "$oid_commit2_failverify" "${#content_commit2_failverify}"
|
|
|
|
assert_local_object "$oid_commit3" "${#content_commit3}"
|
2015-10-15 13:49:19 +00:00
|
|
|
|
|
|
|
# Now test with the global option
|
|
|
|
git config lfs.pruneverifyremotealways true
|
|
|
|
# no verify arg but should be pulled from global
|
|
|
|
git lfs prune 2>&1 | tee prune.log
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 4 local objects, 1 retained, 2 verified with remote, done." prune.log
|
2015-10-15 13:49:19 +00:00
|
|
|
grep "missing on remote:" prune.log
|
|
|
|
grep "$oid_commit2_failverify" prune.log
|
|
|
|
# Nothing should have been deleted
|
|
|
|
assert_local_object "$oid_commit1" "${#content_commit1}"
|
|
|
|
assert_local_object "$oid_commit2_failverify" "${#content_commit2_failverify}"
|
|
|
|
assert_local_object "$oid_commit3" "${#content_commit3}"
|
|
|
|
|
|
|
|
# now try overriding the global option
|
|
|
|
git lfs prune --no-verify-remote 2>&1 | tee prune.log
|
2021-12-13 19:27:02 +00:00
|
|
|
grep "prune: 4 local objects, 1 retained, done." prune.log
|
2019-08-23 21:01:19 +00:00
|
|
|
grep "prune: Deleting objects: 100% (3/3), done." prune.log
|
2015-10-15 13:49:19 +00:00
|
|
|
# should now have been deleted
|
|
|
|
refute_local_object "$oid_commit1"
|
|
|
|
refute_local_object "$oid_commit2_failverify"
|
|
|
|
refute_local_object "$oid_commit3"
|
2017-01-17 04:38:31 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "prune verify large numbers of refs"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_verify_large"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
2017-03-24 16:59:03 +00:00
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
2017-01-17 04:38:31 +00:00
|
|
|
|
|
|
|
content_head="HEAD content"
|
|
|
|
content_commit1="Recent commit"
|
|
|
|
content_oldcommit="Old content"
|
|
|
|
oid_head=$(calc_oid "$content_head")
|
|
|
|
|
|
|
|
# Add two recent commits that should not be pruned
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -50d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_oldcommit}, \"Data\":\"$(uuidgen)\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -45d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_oldcommit}, \"Data\":\"$(uuidgen)\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -2d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_commit1}, \"Data\":\"$content_commit1\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -1d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_head}, \"Data\":\"$content_head\"}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
|
|
|
# Generate a large number of refs to old commits make sure prune has a lot of data to read
|
2020-06-29 16:18:57 +00:00
|
|
|
git checkout $(git log --pretty=oneline main | tail -2 | awk '{print $1}' | head -1)
|
2017-01-17 04:38:31 +00:00
|
|
|
for i in $(seq 0 1000); do
|
|
|
|
git tag v$i
|
|
|
|
done
|
2020-06-29 16:18:57 +00:00
|
|
|
git checkout main
|
2017-01-17 04:38:31 +00:00
|
|
|
|
|
|
|
# push all so no unpushed reason to not prune
|
2020-06-29 16:18:57 +00:00
|
|
|
# git push origin main
|
2017-01-17 04:38:31 +00:00
|
|
|
|
|
|
|
# set no recents so max ability to prune normally
|
|
|
|
git config lfs.fetchrecentrefsdays 3
|
|
|
|
git config lfs.fetchrecentremoterefs true
|
|
|
|
git config lfs.fetchrecentcommitsdays 3
|
|
|
|
git config lfs.pruneoffsetdays 3
|
|
|
|
|
|
|
|
# confirm that prune does not hang
|
|
|
|
git lfs prune --dry-run --verify-remote --verbose 2>&1 | tee prune.log
|
|
|
|
|
2015-10-09 15:55:19 +00:00
|
|
|
)
|
2017-03-24 16:59:03 +00:00
|
|
|
end_test
|
2020-08-07 15:48:59 +00:00
|
|
|
|
|
|
|
begin_test "prune keep stashed changes"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_keep_stashed"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
|
|
|
|
# generate content we'll use
|
2021-03-23 08:10:30 +00:00
|
|
|
content_oldandpushed="To delete: pushed and too old"
|
|
|
|
oid_oldandpushed=$(calc_oid "$content_oldandpushed")
|
2021-03-24 06:22:08 +00:00
|
|
|
content_unreferenced="To delete: unreferenced"
|
|
|
|
oid_unreferenced=$(calc_oid "$content_unreferenced")
|
2021-03-23 08:10:30 +00:00
|
|
|
content_retain1="Retained content 1"
|
|
|
|
oid_retain1=$(calc_oid "$content_retain1")
|
|
|
|
|
2020-08-07 15:48:59 +00:00
|
|
|
content_inrepo="This is the original committed data"
|
|
|
|
oid_inrepo=$(calc_oid "$content_inrepo")
|
|
|
|
content_stashed="This data will be stashed and should not be deleted"
|
|
|
|
oid_stashed=$(calc_oid "$content_stashed")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_stashedandexcluded="This data will be stashed and should not be deleted despite being excluded"
|
|
|
|
oid_stashedandexcluded=$(calc_oid "$content_stashedandexcluded")
|
2021-03-24 06:27:38 +00:00
|
|
|
content_stashedbranch="This data will be stashed on a branch and should not be deleted"
|
|
|
|
oid_stashedbranch=$(calc_oid "$content_stashedbranch")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_stashedandexcludedbranch="This data will be stashed on a branch and should not be deleted despite being excluded"
|
|
|
|
oid_stashedandexcludedbranch=$(calc_oid "$content_stashedandexcludedbranch")
|
2020-08-07 15:48:59 +00:00
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
# We need to test with older commits to ensure they get pruned as expected
|
2020-08-07 15:48:59 +00:00
|
|
|
echo "[
|
2021-03-23 08:10:30 +00:00
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -20d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"old.dat\",\"Size\":${#content_oldandpushed}, \"Data\":\"$content_oldandpushed\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"old.dat\",\"Size\":${#content_retain1}, \"Data\":\"$content_retain1\"}]
|
|
|
|
},
|
2021-03-24 06:22:08 +00:00
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -4d)\",
|
|
|
|
\"NewBranch\":\"branch_to_delete\",
|
|
|
|
\"Files\":[
|
2022-04-25 03:04:59 +00:00
|
|
|
{\"Filename\":\"unreferenced.dat\",\"Size\":${#content_unreferenced}, \"Data\":\"$content_unreferenced\"},
|
|
|
|
{\"Filename\":\"foo/unreferenced.dat\",\"Size\":${#content_unreferenced}, \"Data\":\"$content_unreferenced\"}]
|
2021-03-24 06:22:08 +00:00
|
|
|
},
|
2020-08-07 15:48:59 +00:00
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -1d)\",
|
2021-03-24 06:22:08 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2020-08-07 15:48:59 +00:00
|
|
|
\"Files\":[
|
2022-04-25 03:04:59 +00:00
|
|
|
{\"Filename\":\"stashedfile.dat\",\"Size\":${#content_inrepo}, \"Data\":\"$content_inrepo\"},
|
|
|
|
{\"Filename\":\"foo/stashedfile.dat\",\"Size\":${#content_inrepo}, \"Data\":\"$content_inrepo\"}]
|
2020-08-07 15:48:59 +00:00
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
git push origin main
|
|
|
|
|
|
|
|
assert_local_object "$oid_oldandpushed" "${#content_oldandpushed}"
|
2021-03-24 06:22:08 +00:00
|
|
|
assert_local_object "$oid_unreferenced" "${#content_unreferenced}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_retain1" "${#content_retain1}"
|
|
|
|
|
2022-04-25 03:04:59 +00:00
|
|
|
# now modify the files, and stash them
|
2020-09-03 23:29:22 +00:00
|
|
|
printf '%s' "$content_stashed" > stashedfile.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_stashedandexcluded" > foo/stashedfile.dat
|
2021-03-24 06:27:38 +00:00
|
|
|
git stash
|
2020-08-10 08:48:39 +00:00
|
|
|
|
2022-04-25 03:04:59 +00:00
|
|
|
# Switch to a branch, modify files, stash them, and delete the branch.
|
2021-03-24 06:27:38 +00:00
|
|
|
git checkout branch_to_delete
|
|
|
|
printf '%s' "$content_stashedbranch" > unreferenced.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_stashedandexcludedbranch" > foo/unreferenced.dat
|
2020-08-07 15:48:59 +00:00
|
|
|
git stash
|
2021-03-24 06:27:38 +00:00
|
|
|
git checkout main
|
2021-03-24 06:22:08 +00:00
|
|
|
git branch -D branch_to_delete
|
2020-08-07 15:48:59 +00:00
|
|
|
|
|
|
|
# Prove that the stashed data was stored in LFS (should call clean filter)
|
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcluded" "${#content_stashedandexcluded}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_stashedbranch" "${#content_stashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcludedbranch" "${#content_stashedandexcludedbranch}"
|
|
|
|
|
|
|
|
# We need to prevent MSYS from rewriting /foo into a Windows path.
|
commands,t: gitignore matching for fetch filters
The "lfs.fetchinclude" and "lfs.fetchexclude" Git configuration
options, if set, are used to control the action of a number of Git
LFS commands. Since PR #4556, the "git lfs clone", "git lfs fetch",
and "git lfs pull" commands have strictly applied gitignore(5)-style
matching rules to these configuration options.
However, other commands including "git lfs filter-process" and
"git lfs smudge" now apply gitattributes(5)-style matching
rules to these same configuration options, leading to confusion.
We therefore revise all remaining uses of these configuration
options to also use gitignore-style matching rules.
We also add new tests for the "git lfs filter-process" and "git lfs
fsck" commands and adjust or expand existing tests for the "git lfs
prune" and "git lfs smudge" commands in order to confirm that
gitignore-style matching is used for all of them. These new and
updated tests fail if gitattributes-style matching is used instead.
(Note that the "git lfs migrate" command does not require any changes
because it does not read the "lfs.fetch*" configuration options.
Instead, it supplies a "false" value for the "useFetchOptions" flag
to the determineIncludeExcludePaths() function, so any "lfs.fetch*"
configuration values are ignored. This is significant because
"git lfs migrate" deliberately uses gitattributes-style matching
for any path patterns supplied via its -I/-X command-line arguments,
unlike all other commands that accept -I/-X arguments as overrides
for the "lfs.fetch*" configuration options.)
2022-04-18 07:24:53 +00:00
|
|
|
MSYS_NO_PATHCONV=1 git config "lfs.fetchexclude" "/foo"
|
2020-08-07 15:48:59 +00:00
|
|
|
|
2021-08-18 01:31:41 +00:00
|
|
|
# force color codes in git diff meta-information
|
|
|
|
git config color.diff always
|
|
|
|
|
2021-03-24 06:27:38 +00:00
|
|
|
# Prune data, should NOT delete stashed files
|
2020-08-07 15:48:59 +00:00
|
|
|
git lfs prune
|
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
refute_local_object "$oid_oldandpushed" "${#content_oldandpushed}"
|
2021-03-24 06:22:08 +00:00
|
|
|
refute_local_object "$oid_unreferenced" "${#content_unreferenced}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_retain1" "${#content_retain1}"
|
2020-08-07 15:48:59 +00:00
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcluded" "${#content_stashedandexcluded}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_stashedbranch" "${#content_stashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcludedbranch" "${#content_stashedandexcludedbranch}"
|
2020-08-07 15:48:59 +00:00
|
|
|
)
|
2020-08-08 10:12:09 +00:00
|
|
|
end_test
|
2020-08-08 10:27:46 +00:00
|
|
|
|
2020-08-12 14:30:47 +00:00
|
|
|
begin_test "prune keep stashed changes in index"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_keep_stashed_index"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
|
|
|
|
# generate content we'll use
|
2021-03-23 08:10:30 +00:00
|
|
|
content_oldandpushed="To delete: pushed and too old"
|
|
|
|
oid_oldandpushed=$(calc_oid "$content_oldandpushed")
|
2021-03-24 06:22:08 +00:00
|
|
|
content_unreferenced="To delete: unreferenced"
|
|
|
|
oid_unreferenced=$(calc_oid "$content_unreferenced")
|
2021-03-23 08:10:30 +00:00
|
|
|
content_retain1="Retained content 1"
|
|
|
|
oid_retain1=$(calc_oid "$content_retain1")
|
|
|
|
|
2020-08-12 14:30:47 +00:00
|
|
|
content_inrepo="This is the original committed data"
|
|
|
|
oid_inrepo=$(calc_oid "$content_inrepo")
|
|
|
|
content_indexstashed="This data will be stashed from the index and should not be deleted"
|
|
|
|
oid_indexstashed=$(calc_oid "$content_indexstashed")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_indexstashedandexcluded="This data will be stashed from the index and should not be deleted despite being excluded"
|
|
|
|
oid_indexstashedandexcluded=$(calc_oid "$content_indexstashedandexcluded")
|
2020-08-12 14:30:47 +00:00
|
|
|
content_stashed="This data will be stashed and should not be deleted"
|
|
|
|
oid_stashed=$(calc_oid "$content_stashed")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_stashedandexcluded="This data will be stashed and should not be deleted despite being excluded"
|
|
|
|
oid_stashedandexcluded=$(calc_oid "$content_stashedandexcluded")
|
2021-03-24 06:27:38 +00:00
|
|
|
content_indexstashedbranch="This data will be stashed on a branch from the index and should not be deleted"
|
|
|
|
oid_indexstashedbranch=$(calc_oid "$content_indexstashedbranch")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_indexstashedandexcludedbranch="This data will be stashed on a branch from the index and should not be deleted despite being excluded"
|
|
|
|
oid_indexstashedandexcludedbranch=$(calc_oid "$content_indexstashedandexcludedbranch")
|
2021-03-24 06:27:38 +00:00
|
|
|
content_stashedbranch="This data will be stashed on a branch and should not be deleted"
|
|
|
|
oid_stashedbranch=$(calc_oid "$content_stashedbranch")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_stashedandexcludedbranch="This data will be stashed on a branch and should not be deleted despite being excluded"
|
|
|
|
oid_stashedandexcludedbranch=$(calc_oid "$content_stashedandexcludedbranch")
|
2020-08-12 14:30:47 +00:00
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
# We need to test with older commits to ensure they get pruned as expected
|
2020-08-12 14:30:47 +00:00
|
|
|
echo "[
|
2021-03-23 08:10:30 +00:00
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -20d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"old.dat\",\"Size\":${#content_oldandpushed}, \"Data\":\"$content_oldandpushed\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"old.dat\",\"Size\":${#content_retain1}, \"Data\":\"$content_retain1\"}]
|
|
|
|
},
|
2021-03-24 06:22:08 +00:00
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -4d)\",
|
|
|
|
\"NewBranch\":\"branch_to_delete\",
|
|
|
|
\"Files\":[
|
2022-04-25 03:04:59 +00:00
|
|
|
{\"Filename\":\"unreferenced.dat\",\"Size\":${#content_unreferenced}, \"Data\":\"$content_unreferenced\"},
|
|
|
|
{\"Filename\":\"foo/unreferenced.dat\",\"Size\":${#content_unreferenced}, \"Data\":\"$content_unreferenced\"}]
|
2021-03-24 06:22:08 +00:00
|
|
|
},
|
2020-08-12 14:30:47 +00:00
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -1d)\",
|
2021-03-24 06:22:08 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2020-08-12 14:30:47 +00:00
|
|
|
\"Files\":[
|
2022-04-25 03:04:59 +00:00
|
|
|
{\"Filename\":\"stashedfile.dat\",\"Size\":${#content_inrepo}, \"Data\":\"$content_inrepo\"},
|
|
|
|
{\"Filename\":\"foo/stashedfile.dat\",\"Size\":${#content_inrepo}, \"Data\":\"$content_inrepo\"}]
|
2020-08-12 14:30:47 +00:00
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
git push origin main
|
|
|
|
|
|
|
|
assert_local_object "$oid_oldandpushed" "${#content_oldandpushed}"
|
2021-03-24 06:22:08 +00:00
|
|
|
assert_local_object "$oid_unreferenced" "${#content_unreferenced}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_retain1" "${#content_retain1}"
|
|
|
|
|
2022-04-25 03:04:59 +00:00
|
|
|
# now modify the files, and add them to the index
|
2020-09-03 23:29:22 +00:00
|
|
|
printf '%s' "$content_indexstashed" > stashedfile.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_indexstashedandexcluded" > foo/stashedfile.dat
|
|
|
|
git add stashedfile.dat foo/stashedfile.dat
|
2020-08-12 14:30:47 +00:00
|
|
|
|
2022-04-25 03:04:59 +00:00
|
|
|
# now modify the files again, and stash them
|
2020-09-03 23:29:22 +00:00
|
|
|
printf '%s' "$content_stashed" > stashedfile.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_stashedandexcluded" > foo/stashedfile.dat
|
2021-03-24 06:27:38 +00:00
|
|
|
git stash
|
2020-08-12 14:30:47 +00:00
|
|
|
|
2022-04-25 03:04:59 +00:00
|
|
|
# Switch to a branch, modify files in the index and working tree, stash them,
|
|
|
|
# and delete the branch.
|
2021-03-24 06:27:38 +00:00
|
|
|
git checkout branch_to_delete
|
|
|
|
printf '%s' "$content_indexstashedbranch" > unreferenced.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_indexstashedandexcludedbranch" > foo/unreferenced.dat
|
|
|
|
git add unreferenced.dat foo/unreferenced.dat
|
2021-03-24 06:27:38 +00:00
|
|
|
printf '%s' "$content_stashedbranch" > unreferenced.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_stashedandexcludedbranch" > foo/unreferenced.dat
|
2020-08-12 14:30:47 +00:00
|
|
|
git stash
|
2021-03-24 06:27:38 +00:00
|
|
|
git checkout main
|
2021-03-24 06:22:08 +00:00
|
|
|
git branch -D branch_to_delete
|
2020-08-12 14:30:47 +00:00
|
|
|
|
|
|
|
# Prove that the stashed data was stored in LFS (should call clean filter)
|
|
|
|
assert_local_object "$oid_indexstashed" "${#content_indexstashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_indexstashedandexcluded" "${#content_indexstashedandexcluded}"
|
2021-03-24 05:34:45 +00:00
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcluded" "${#content_stashedandexcluded}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_indexstashedbranch" "${#content_indexstashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_indexstashedandexcludedbranch" "${#content_indexstashedandexcludedbranch}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_stashedbranch" "${#content_stashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcludedbranch" "${#content_stashedandexcludedbranch}"
|
|
|
|
|
|
|
|
# We need to prevent MSYS from rewriting /foo into a Windows path.
|
commands,t: gitignore matching for fetch filters
The "lfs.fetchinclude" and "lfs.fetchexclude" Git configuration
options, if set, are used to control the action of a number of Git
LFS commands. Since PR #4556, the "git lfs clone", "git lfs fetch",
and "git lfs pull" commands have strictly applied gitignore(5)-style
matching rules to these configuration options.
However, other commands including "git lfs filter-process" and
"git lfs smudge" now apply gitattributes(5)-style matching
rules to these same configuration options, leading to confusion.
We therefore revise all remaining uses of these configuration
options to also use gitignore-style matching rules.
We also add new tests for the "git lfs filter-process" and "git lfs
fsck" commands and adjust or expand existing tests for the "git lfs
prune" and "git lfs smudge" commands in order to confirm that
gitignore-style matching is used for all of them. These new and
updated tests fail if gitattributes-style matching is used instead.
(Note that the "git lfs migrate" command does not require any changes
because it does not read the "lfs.fetch*" configuration options.
Instead, it supplies a "false" value for the "useFetchOptions" flag
to the determineIncludeExcludePaths() function, so any "lfs.fetch*"
configuration values are ignored. This is significant because
"git lfs migrate" deliberately uses gitattributes-style matching
for any path patterns supplied via its -I/-X command-line arguments,
unlike all other commands that accept -I/-X arguments as overrides
for the "lfs.fetch*" configuration options.)
2022-04-18 07:24:53 +00:00
|
|
|
MSYS_NO_PATHCONV=1 git config "lfs.fetchexclude" "/foo"
|
2020-08-12 14:30:47 +00:00
|
|
|
|
2021-08-18 01:31:41 +00:00
|
|
|
# force color codes in git diff meta-information
|
|
|
|
git config color.diff always
|
|
|
|
|
2020-08-12 14:30:47 +00:00
|
|
|
# Prune data, should NOT delete stashed file or stashed changes to index
|
|
|
|
git lfs prune
|
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
refute_local_object "$oid_oldandpushed" "${#content_oldandpushed}"
|
2021-03-24 06:22:08 +00:00
|
|
|
refute_local_object "$oid_unreferenced" "${#content_unreferenced}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_retain1" "${#content_retain1}"
|
2020-08-12 14:30:47 +00:00
|
|
|
assert_local_object "$oid_indexstashed" "${#content_indexstashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_indexstashedandexcluded" "${#content_indexstashedandexcluded}"
|
2021-03-24 05:34:45 +00:00
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcluded" "${#content_stashedandexcluded}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_indexstashedbranch" "${#content_indexstashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_indexstashedandexcludedbranch" "${#content_indexstashedandexcludedbranch}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_stashedbranch" "${#content_stashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcludedbranch" "${#content_stashedandexcludedbranch}"
|
2020-08-12 14:30:47 +00:00
|
|
|
)
|
|
|
|
end_test
|
2020-08-13 13:32:26 +00:00
|
|
|
|
|
|
|
begin_test "prune keep stashed untracked files"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_keep_stashed_untracked"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
|
2021-03-24 06:27:38 +00:00
|
|
|
# Commit .gitattributes first so it is not removed by "git stash -u" and then
|
|
|
|
# not restored when we checkout the branch and try to modify LFS objects.
|
|
|
|
git add .gitattributes
|
|
|
|
git commit -m attribs
|
|
|
|
|
2020-08-13 13:32:26 +00:00
|
|
|
# generate content we'll use
|
2021-03-23 08:10:30 +00:00
|
|
|
content_oldandpushed="To delete: pushed and too old"
|
|
|
|
oid_oldandpushed=$(calc_oid "$content_oldandpushed")
|
2021-03-24 06:22:08 +00:00
|
|
|
content_unreferenced="To delete: unreferenced"
|
|
|
|
oid_unreferenced=$(calc_oid "$content_unreferenced")
|
2021-03-23 08:10:30 +00:00
|
|
|
content_retain1="Retained content 1"
|
|
|
|
oid_retain1=$(calc_oid "$content_retain1")
|
|
|
|
|
2020-08-13 13:32:26 +00:00
|
|
|
content_inrepo="This is the original committed data"
|
|
|
|
oid_inrepo=$(calc_oid "$content_inrepo")
|
|
|
|
content_indexstashed="This data will be stashed from the index and should not be deleted"
|
|
|
|
oid_indexstashed=$(calc_oid "$content_indexstashed")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_indexstashedandexcluded="This data will be stashed from the index and should not be deleted despite being excluded"
|
|
|
|
oid_indexstashedandexcluded=$(calc_oid "$content_indexstashedandexcluded")
|
2020-08-13 13:32:26 +00:00
|
|
|
content_stashed="This data will be stashed and should not be deleted"
|
|
|
|
oid_stashed=$(calc_oid "$content_stashed")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_stashedandexcluded="This data will be stashed and should not be deleted despite being excluded"
|
|
|
|
oid_stashedandexcluded=$(calc_oid "$content_stashedandexcluded")
|
2020-08-13 13:32:26 +00:00
|
|
|
content_untrackedstashed="This UNTRACKED FILE data will be stashed and should not be deleted"
|
|
|
|
oid_untrackedstashed=$(calc_oid "$content_untrackedstashed")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_untrackedstashedandexcluded="This UNTRACKED FILE data will be stashed and should not be deleted despite being excluded"
|
|
|
|
oid_untrackedstashedandexcluded=$(calc_oid "$content_untrackedstashedandexcluded")
|
2021-03-24 06:27:38 +00:00
|
|
|
content_indexstashedbranch="This data will be stashed on a branch from the index and should not be deleted"
|
|
|
|
oid_indexstashedbranch=$(calc_oid "$content_indexstashedbranch")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_indexstashedandexcludedbranch="This data will be stashed on a branch from the index and should not be deleted despite being excluded"
|
|
|
|
oid_indexstashedandexcludedbranch=$(calc_oid "$content_indexstashedandexcludedbranch")
|
2021-03-24 06:27:38 +00:00
|
|
|
content_stashedbranch="This data will be stashed on a branch and should not be deleted"
|
|
|
|
oid_stashedbranch=$(calc_oid "$content_stashedbranch")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_stashedandexcludedbranch="This data will be stashed on a branch and should not be deleted despite being excluded"
|
|
|
|
oid_stashedandexcludedbranch=$(calc_oid "$content_stashedandexcludedbranch")
|
2021-03-24 06:27:38 +00:00
|
|
|
content_untrackedstashedbranch="This UNTRACKED FILE data will be stashed on a branch and should not be deleted"
|
|
|
|
oid_untrackedstashedbranch=$(calc_oid "$content_untrackedstashedbranch")
|
2022-04-25 03:04:59 +00:00
|
|
|
content_untrackedstashedandexcludedbranch="This UNTRACKED FILE data will be stashed on a branch and should not be deleted despite being excluded"
|
|
|
|
oid_untrackedstashedandexcludedbranch=$(calc_oid "$content_untrackedstashedandexcludedbranch")
|
2020-08-13 13:32:26 +00:00
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
# We need to test with older commits to ensure they get pruned as expected
|
2020-08-13 13:32:26 +00:00
|
|
|
echo "[
|
2021-03-23 08:10:30 +00:00
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -20d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"old.dat\",\"Size\":${#content_oldandpushed}, \"Data\":\"$content_oldandpushed\"}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -7d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"old.dat\",\"Size\":${#content_retain1}, \"Data\":\"$content_retain1\"}]
|
|
|
|
},
|
2021-03-24 06:22:08 +00:00
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -4d)\",
|
|
|
|
\"NewBranch\":\"branch_to_delete\",
|
|
|
|
\"Files\":[
|
2022-04-25 03:04:59 +00:00
|
|
|
{\"Filename\":\"unreferenced.dat\",\"Size\":${#content_unreferenced}, \"Data\":\"$content_unreferenced\"},
|
|
|
|
{\"Filename\":\"foo/unreferenced.dat\",\"Size\":${#content_unreferenced}, \"Data\":\"$content_unreferenced\"}]
|
2021-03-24 06:22:08 +00:00
|
|
|
},
|
2020-08-13 13:32:26 +00:00
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -1d)\",
|
2021-03-24 06:22:08 +00:00
|
|
|
\"ParentBranches\":[\"main\"],
|
2020-08-13 13:32:26 +00:00
|
|
|
\"Files\":[
|
2022-04-25 03:04:59 +00:00
|
|
|
{\"Filename\":\"stashedfile.dat\",\"Size\":${#content_inrepo}, \"Data\":\"$content_inrepo\"},
|
|
|
|
{\"Filename\":\"foo/stashedfile.dat\",\"Size\":${#content_inrepo}, \"Data\":\"$content_inrepo\"}]
|
2020-08-13 13:32:26 +00:00
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
git push origin main
|
|
|
|
|
|
|
|
assert_local_object "$oid_oldandpushed" "${#content_oldandpushed}"
|
2021-03-24 06:22:08 +00:00
|
|
|
assert_local_object "$oid_unreferenced" "${#content_unreferenced}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_retain1" "${#content_retain1}"
|
|
|
|
|
2022-04-25 03:04:59 +00:00
|
|
|
# now modify the files, and add them to the index
|
2020-09-03 23:29:22 +00:00
|
|
|
printf '%s' "$content_indexstashed" > stashedfile.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_indexstashedandexcluded" > foo/stashedfile.dat
|
|
|
|
git add stashedfile.dat foo/stashedfile.dat
|
2020-08-13 13:32:26 +00:00
|
|
|
|
2022-04-25 03:04:59 +00:00
|
|
|
# now modify the files again, and stash them
|
2020-09-03 23:29:22 +00:00
|
|
|
printf '%s' "$content_stashed" > stashedfile.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_stashedandexcluded" > foo/stashedfile.dat
|
2020-08-13 13:32:26 +00:00
|
|
|
|
2022-04-25 03:04:59 +00:00
|
|
|
# Also create untracked files
|
2020-09-03 23:29:22 +00:00
|
|
|
printf '%s' "$content_untrackedstashed" > untrackedfile.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_untrackedstashedandexcluded" > foo/untrackedfile.dat
|
2020-08-13 13:32:26 +00:00
|
|
|
|
|
|
|
# stash, including untracked
|
|
|
|
git stash -u
|
2021-03-24 06:27:38 +00:00
|
|
|
|
2022-04-25 03:04:59 +00:00
|
|
|
# Switch to a branch, modify files in the index and working tree and create
|
|
|
|
# untracked files, stash them, and delete the branch.
|
2021-03-24 06:27:38 +00:00
|
|
|
git checkout branch_to_delete
|
|
|
|
printf '%s' "$content_indexstashedbranch" > unreferenced.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_indexstashedandexcludedbranch" > foo/unreferenced.dat
|
|
|
|
git add unreferenced.dat foo/unreferenced.dat
|
2021-03-24 06:27:38 +00:00
|
|
|
printf '%s' "$content_stashedbranch" > unreferenced.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_stashedandexcludedbranch" > foo/unreferenced.dat
|
2021-03-24 06:27:38 +00:00
|
|
|
printf '%s' "$content_untrackedstashedbranch" > untrackedfile.dat
|
2022-04-25 03:04:59 +00:00
|
|
|
printf '%s' "$content_untrackedstashedandexcludedbranch" > foo/untrackedfile.dat
|
2021-03-24 06:27:38 +00:00
|
|
|
git stash -u
|
|
|
|
git checkout main
|
2021-03-24 06:22:08 +00:00
|
|
|
git branch -D branch_to_delete
|
2020-08-13 13:32:26 +00:00
|
|
|
|
|
|
|
# Prove that ALL stashed data was stored in LFS (should call clean filter)
|
|
|
|
assert_local_object "$oid_indexstashed" "${#content_indexstashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_indexstashedandexcluded" "${#content_indexstashedandexcluded}"
|
2021-03-24 05:34:45 +00:00
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcluded" "${#content_stashedandexcluded}"
|
2020-08-13 13:32:26 +00:00
|
|
|
assert_local_object "$oid_untrackedstashed" "${#content_untrackedstashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_untrackedstashedandexcluded" "${#content_untrackedstashedandexcluded}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_indexstashedbranch" "${#content_indexstashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_indexstashedandexcludedbranch" "${#content_indexstashedandexcludedbranch}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_stashedbranch" "${#content_stashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcludedbranch" "${#content_stashedandexcludedbranch}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_untrackedstashedbranch" "${#content_untrackedstashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_untrackedstashedandexcludedbranch" "${#content_untrackedstashedandexcludedbranch}"
|
|
|
|
|
|
|
|
# We need to prevent MSYS from rewriting /foo into a Windows path.
|
commands,t: gitignore matching for fetch filters
The "lfs.fetchinclude" and "lfs.fetchexclude" Git configuration
options, if set, are used to control the action of a number of Git
LFS commands. Since PR #4556, the "git lfs clone", "git lfs fetch",
and "git lfs pull" commands have strictly applied gitignore(5)-style
matching rules to these configuration options.
However, other commands including "git lfs filter-process" and
"git lfs smudge" now apply gitattributes(5)-style matching
rules to these same configuration options, leading to confusion.
We therefore revise all remaining uses of these configuration
options to also use gitignore-style matching rules.
We also add new tests for the "git lfs filter-process" and "git lfs
fsck" commands and adjust or expand existing tests for the "git lfs
prune" and "git lfs smudge" commands in order to confirm that
gitignore-style matching is used for all of them. These new and
updated tests fail if gitattributes-style matching is used instead.
(Note that the "git lfs migrate" command does not require any changes
because it does not read the "lfs.fetch*" configuration options.
Instead, it supplies a "false" value for the "useFetchOptions" flag
to the determineIncludeExcludePaths() function, so any "lfs.fetch*"
configuration values are ignored. This is significant because
"git lfs migrate" deliberately uses gitattributes-style matching
for any path patterns supplied via its -I/-X command-line arguments,
unlike all other commands that accept -I/-X arguments as overrides
for the "lfs.fetch*" configuration options.)
2022-04-18 07:24:53 +00:00
|
|
|
MSYS_NO_PATHCONV=1 git config "lfs.fetchexclude" "/foo"
|
2020-08-13 13:32:26 +00:00
|
|
|
|
2021-08-18 01:31:41 +00:00
|
|
|
# force color codes in git diff meta-information
|
|
|
|
git config color.diff always
|
|
|
|
|
2020-08-13 13:32:26 +00:00
|
|
|
# Prune data, should NOT delete stashed file or stashed changes to index
|
|
|
|
git lfs prune
|
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
refute_local_object "$oid_oldandpushed" "${#content_oldandpushed}"
|
2021-03-24 06:22:08 +00:00
|
|
|
refute_local_object "$oid_unreferenced" "${#content_unreferenced}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_retain1" "${#content_retain1}"
|
2020-08-13 13:32:26 +00:00
|
|
|
assert_local_object "$oid_indexstashed" "${#content_indexstashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_indexstashedandexcluded" "${#content_indexstashedandexcluded}"
|
2021-03-24 05:34:45 +00:00
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcluded" "${#content_stashedandexcluded}"
|
2020-08-13 13:32:26 +00:00
|
|
|
assert_local_object "$oid_untrackedstashed" "${#content_untrackedstashed}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_untrackedstashedandexcluded" "${#content_untrackedstashedandexcluded}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_indexstashedbranch" "${#content_indexstashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_indexstashedandexcludedbranch" "${#content_indexstashedandexcludedbranch}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_stashedbranch" "${#content_stashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_stashedandexcludedbranch" "${#content_stashedandexcludedbranch}"
|
2021-03-24 06:27:38 +00:00
|
|
|
assert_local_object "$oid_untrackedstashedbranch" "${#content_untrackedstashedbranch}"
|
2022-04-25 03:04:59 +00:00
|
|
|
assert_local_object "$oid_untrackedstashedandexcludedbranch" "${#content_untrackedstashedandexcludedbranch}"
|
2020-08-13 13:32:26 +00:00
|
|
|
)
|
|
|
|
end_test
|
2021-01-12 21:24:44 +00:00
|
|
|
|
|
|
|
begin_test "prune recent changes with --recent"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_recent_arg"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
|
|
|
|
# generate content we'll use
|
|
|
|
content_inrepo="this is the original committed data"
|
|
|
|
oid_inrepo=$(calc_oid "$content_inrepo")
|
|
|
|
content_new="this data will be recent"
|
|
|
|
oid_new=$(calc_oid "$content_new")
|
2021-03-23 08:10:30 +00:00
|
|
|
content_stashed="This data will be stashed and should not be deleted"
|
|
|
|
oid_stashed=$(calc_oid "$content_stashed")
|
2021-01-12 21:24:44 +00:00
|
|
|
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -1d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_inrepo}, \"Data\":\"$content_inrepo\"}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
# now modify the file, and commit it
|
2021-01-12 21:24:44 +00:00
|
|
|
printf '%s' "$content_new" > file.dat
|
|
|
|
git add .
|
|
|
|
git commit -m 'Update file.dat'
|
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
# now modify the file, and stash it
|
|
|
|
printf '%s' "$content_stashed" > file.dat
|
|
|
|
git stash
|
|
|
|
|
2021-01-12 21:24:44 +00:00
|
|
|
git config lfs.fetchrecentrefsdays 5
|
|
|
|
git config lfs.fetchrecentremoterefs true
|
|
|
|
git config lfs.fetchrecentcommitsdays 3
|
|
|
|
|
|
|
|
assert_local_object "$oid_new" "${#content_new}"
|
|
|
|
assert_local_object "$oid_inrepo" "${#content_inrepo}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2021-01-12 21:24:44 +00:00
|
|
|
|
|
|
|
# prune data, should not delete.
|
|
|
|
git lfs prune --recent
|
|
|
|
|
|
|
|
assert_local_object "$oid_new" "${#content_new}"
|
|
|
|
assert_local_object "$oid_inrepo" "${#content_inrepo}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2021-01-12 21:24:44 +00:00
|
|
|
|
|
|
|
git push origin HEAD
|
|
|
|
|
|
|
|
# prune data.
|
|
|
|
git lfs prune --recent
|
|
|
|
|
|
|
|
assert_local_object "$oid_new" "${#content_new}"
|
|
|
|
refute_local_object "$oid_inrepo" "${#content_inrepo}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2021-01-12 21:24:44 +00:00
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "prune --force"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_force"
|
|
|
|
setup_remote_repo "remote_$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote_$reponame" "clone_$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat"
|
|
|
|
|
|
|
|
# generate content we'll use
|
|
|
|
content_inrepo="this is the original committed data"
|
|
|
|
oid_inrepo=$(calc_oid "$content_inrepo")
|
|
|
|
content_new="this data will be recent"
|
|
|
|
oid_new=$(calc_oid "$content_new")
|
2021-03-23 08:10:30 +00:00
|
|
|
content_stashed="This data will be stashed and should not be deleted"
|
|
|
|
oid_stashed=$(calc_oid "$content_stashed")
|
2021-01-12 21:24:44 +00:00
|
|
|
|
|
|
|
echo "[
|
|
|
|
{
|
|
|
|
\"CommitDate\":\"$(get_date -1d)\",
|
|
|
|
\"Files\":[
|
|
|
|
{\"Filename\":\"file.dat\",\"Size\":${#content_inrepo}, \"Data\":\"$content_inrepo\"}]
|
|
|
|
}
|
|
|
|
]" | lfstest-testutils addcommits
|
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
# now modify the file, and commit it
|
2021-01-12 21:24:44 +00:00
|
|
|
printf '%s' "$content_new" > file.dat
|
|
|
|
git add .
|
|
|
|
git commit -m 'Update file.dat'
|
|
|
|
|
2021-03-23 08:10:30 +00:00
|
|
|
# now modify the file, and stash it
|
|
|
|
printf '%s' "$content_stashed" > file.dat
|
|
|
|
git stash
|
|
|
|
|
2021-01-12 21:24:44 +00:00
|
|
|
git config lfs.fetchrecentrefsdays 5
|
|
|
|
git config lfs.fetchrecentremoterefs true
|
|
|
|
git config lfs.fetchrecentcommitsdays 3
|
|
|
|
|
|
|
|
assert_local_object "$oid_new" "${#content_new}"
|
|
|
|
assert_local_object "$oid_inrepo" "${#content_inrepo}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2021-01-12 21:24:44 +00:00
|
|
|
|
|
|
|
# prune data, should not delete.
|
|
|
|
git lfs prune --force
|
|
|
|
|
|
|
|
assert_local_object "$oid_new" "${#content_new}"
|
|
|
|
assert_local_object "$oid_inrepo" "${#content_inrepo}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2021-01-12 21:24:44 +00:00
|
|
|
|
|
|
|
git push origin HEAD
|
|
|
|
|
|
|
|
# prune data.
|
|
|
|
git lfs prune --force
|
|
|
|
|
|
|
|
refute_local_object "$oid_new" "${#content_new}"
|
|
|
|
refute_local_object "$oid_inrepo" "${#content_inrepo}"
|
2021-03-23 08:10:30 +00:00
|
|
|
assert_local_object "$oid_stashed" "${#content_stashed}"
|
2021-01-12 21:24:44 +00:00
|
|
|
)
|
|
|
|
end_test
|
2021-02-19 17:36:27 +00:00
|
|
|
|
2021-09-27 12:33:22 +00:00
|
|
|
begin_test "prune does not fail on empty files"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune-empty-file"
|
|
|
|
setup_remote_repo "remote-$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote-$reponame" "clone-$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
|
|
|
|
touch empty.dat
|
|
|
|
git add .gitattributes empty.dat
|
|
|
|
git commit -m 'Add empty'
|
|
|
|
git push origin main
|
|
|
|
|
|
|
|
git lfs prune --force
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
2021-02-19 17:36:27 +00:00
|
|
|
begin_test "prune does not invoke external diff programs"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune-external-diff"
|
|
|
|
setup_remote_repo "remote-$reponame"
|
|
|
|
|
|
|
|
clone_repo "remote-$reponame" "clone-$reponame"
|
|
|
|
|
|
|
|
git config diff.word.textconv 'false'
|
|
|
|
echo "*.dot diff=word" >.git/info/attributes
|
|
|
|
|
|
|
|
for n in $(seq 1000); do (echo "$n" > "$n.dot") done
|
|
|
|
git add .
|
|
|
|
git commit -am "initial"
|
|
|
|
git lfs prune
|
|
|
|
)
|
|
|
|
end_test
|
2021-07-23 14:54:58 +00:00
|
|
|
|
|
|
|
begin_test "prune doesn't hang on long lines in diff"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_longlines"
|
|
|
|
git init "$reponame"
|
|
|
|
cd "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
|
|
|
|
echo "test data" >test.dat
|
|
|
|
git add .gitattributes test.dat
|
|
|
|
|
|
|
|
git commit -m tracked
|
|
|
|
|
|
|
|
git lfs untrack "*.dat" 2>&1 | tee untrack.log
|
|
|
|
grep "Untracking \"\*.dat\"" untrack.log
|
|
|
|
|
2021-07-23 15:03:21 +00:00
|
|
|
# Exceed the default buffer size that would be used by bufio.Scanner
|
2021-07-23 14:54:58 +00:00
|
|
|
dd if=/dev/zero bs=1024 count=128 | tr '\0' 'A' >test.dat
|
|
|
|
git add .gitattributes test.dat
|
|
|
|
|
|
|
|
git commit -m untracked
|
|
|
|
|
|
|
|
git lfs prune
|
|
|
|
)
|
|
|
|
end_test
|
|
|
|
|
|
|
|
begin_test "prune doesn't hang on long lines in stash diff"
|
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
|
|
|
reponame="prune_longlines"
|
|
|
|
git init "$reponame"
|
|
|
|
cd "$reponame"
|
|
|
|
|
|
|
|
git lfs track "*.dat" 2>&1 | tee track.log
|
|
|
|
grep "Tracking \"\*.dat\"" track.log
|
|
|
|
|
|
|
|
echo "test data" >test.dat
|
|
|
|
git add .gitattributes test.dat
|
|
|
|
|
|
|
|
git commit -m tracked
|
|
|
|
|
|
|
|
git lfs untrack "*.dat" 2>&1 | tee untrack.log
|
|
|
|
grep "Untracking \"\*.dat\"" untrack.log
|
|
|
|
|
2021-07-23 15:03:21 +00:00
|
|
|
# Exceed the default buffer size that would be used by bufio.Scanner
|
2021-07-23 14:54:58 +00:00
|
|
|
dd if=/dev/zero bs=1024 count=128 | tr '\0' 'A' >test.dat
|
|
|
|
git stash
|
|
|
|
|
|
|
|
git lfs prune
|
|
|
|
)
|
|
|
|
end_test
|