Skip to content

Commit 6dc0698

Browse files
committed
t: align missing object push test deletion steps
Our t/t-pre-push.sh and t/t-push-failures-local.sh test scripts include a number of tests which validate the behaviour of the "git lfs pre-push" and "git push" commands when Git LFS objects are missing or corrupt. While these tests are largely similar in their implementation, they vary in a number of formatting and implementation details unrelated to the specifics of the different conditions they simulate. These variations are artifacts of the evolution of our test suite over time; for example, the tests in the t/t-push-failures-local.sh script were refactored and collected from several earlier tests in commit 4d52e08 of PR git-lfs#3109, and the original versions of the tests in the t/t-pre-push.sh script were added incrementally in PRs git-lfs#447, git-lfs#2199, and git-lfs#2574. In a subsequent commit in this PR we expect to update the Git LFS client to remove some non-functional code which attempts to recreate missing Git LFS objects during push operations. In many cases this change will cause the client to report missing objects in an earlier stage of push operations than it does now. We also expect to reword the error message the client will output in such cases. Before we make these changes, we first revise the related tests in our test suite so they are as simple and similar as possible. This will ensure that when we update the Git LFS client we can clearly identify the changes that we need to make in our tests to accommodate the client's new behaviour. In a pair of tests in t/t-pre-push.sh script, and in another pair of tests in the t/t-push-failures-local.sh script, the tests' initial setup code creates several Git LFS objects and then removes the object file in the .git/lfs/objects directory hierarchy for one of them. In each case, we can replace this code with a simple call to our delete_local_object() test helper function, which performs the equivalent action of removing an object's file from the internal Git LFS storage directories.
1 parent 2753452 commit 6dc0698

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

t/t-pre-push.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,7 @@ begin_test "pre-push with missing and present pointers (lfs.allowincompletepush
387387
git rm missing.dat
388388
git commit -m "remove missing"
389389

390-
# :fire: the "missing" object
391-
missing_oid_part_1="$(echo "$missing_oid" | cut -b 1-2)"
392-
missing_oid_part_2="$(echo "$missing_oid" | cut -b 3-4)"
393-
missing_oid_path=".git/lfs/objects/$missing_oid_part_1/$missing_oid_part_2/$missing_oid"
394-
rm "$missing_oid_path"
390+
delete_local_object "$missing_oid"
395391

396392
git config lfs.allowincompletepush true
397393

@@ -438,11 +434,7 @@ begin_test "pre-push reject missing pointers (lfs.allowincompletepush default)"
438434
git rm missing.dat
439435
git commit -m "remove missing"
440436

441-
# :fire: the "missing" object
442-
missing_oid_part_1="$(echo "$missing_oid" | cut -b 1-2)"
443-
missing_oid_part_2="$(echo "$missing_oid" | cut -b 3-4)"
444-
missing_oid_path=".git/lfs/objects/$missing_oid_part_1/$missing_oid_part_2/$missing_oid"
445-
rm "$missing_oid_path"
437+
delete_local_object "$missing_oid"
446438

447439
echo "refs/heads/main main refs/heads/main 0000000000000000000000000000000000000000" |
448440
git lfs pre-push origin "$GITSERVER/$reponame" 2>&1 |

t/t-push-failures-local.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ begin_test "push with missing objects (lfs.allowincompletepush true)"
2828
git rm missing.dat
2929
git commit -m "remove missing"
3030

31-
# :fire: the "missing" object
32-
missing_oid_part_1="$(echo "$missing_oid" | cut -b 1-2)"
33-
missing_oid_part_2="$(echo "$missing_oid" | cut -b 3-4)"
34-
missing_oid_path=".git/lfs/objects/$missing_oid_part_1/$missing_oid_part_2/$missing_oid"
35-
rm "$missing_oid_path"
31+
delete_local_object "$missing_oid"
3632

3733
git config lfs.allowincompletepush true
3834

@@ -76,11 +72,7 @@ begin_test "push reject missing objects (lfs.allowincompletepush false)"
7672
git rm missing.dat
7773
git commit -m "remove missing"
7874

79-
# :fire: the "missing" object
80-
missing_oid_part_1="$(echo "$missing_oid" | cut -b 1-2)"
81-
missing_oid_part_2="$(echo "$missing_oid" | cut -b 3-4)"
82-
missing_oid_path=".git/lfs/objects/$missing_oid_part_1/$missing_oid_part_2/$missing_oid"
83-
rm "$missing_oid_path"
75+
delete_local_object "$missing_oid"
8476

8577
git config lfs.allowincompletepush false
8678

0 commit comments

Comments
 (0)