summaryrefslogtreecommitdiff
path: root/t/t1409-avoid-packing-refs.sh
AgeCommit message (Collapse)AuthorFilesLines
2019-12-20t1409: use test_path_is_missing()Libravatar Denton Liu1-5/+5
The test_must_fail() function should only be used for git commands since we should assume that external commands work sanely. Replace `test_must_fail test -f` with `test_path_is_missing` since we expect these paths to not exist. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-12-20t1409: let sed open its own input fileLibravatar Denton Liu1-1/+1
In one case, we were using a redirection operator to feed input into sed. However, since sed is capable of opening its own input file, make sed do that instead of redirecting input into it. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-12-20t0020: use ! check_packed_refs_markedLibravatar Denton Liu1-2/+2
The test_must_fail function should only be used for git commands since we should assume that external commands work sanely. Since check_packed_refs_marked() just wraps a grep invocation, replace `test_must_fail check_packed_refs_marked` with `! check_packed_refs_marked`. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-30files-backend: don't rewrite the `packed-refs` file unnecessarilyLibravatar Michael Haggerty1-2/+2
Even when we are deleting references, we needn't overwrite the `packed-refs` file if the references that we are deleting only exist as loose references. Implement this optimization as follows: * Add a function `is_packed_transaction_needed()`, which checks whether a given packed-refs transaction actually needs to be carried out (i.e., it returns false if the transaction obviously wouldn't have any effect). This function must be called while holding the `packed-refs` lock to avoid races. * Change `files_transaction_prepare()` to check whether the packed-refs transaction is actually needed. If not, squelch it, but continue holding the `packed-refs` lock until the end of the transaction to avoid races. This fixes a mild regression caused by dc39e09942 (files_ref_store: use a transaction to update packed refs, 2017-09-08). Before that commit, unnecessary rewrites of `packed-refs` were suppressed by `repack_without_refs()`. But the transaction-based writing introduced by that commit didn't perform that optimization. Note that the pre-dc39e09942 code still had to *read* the whole `packed-refs` file to determine that the rewrite could be skipped, so the performance for the cases that the write could be elided was `O(N)` in the number of packed references both before and after dc39e09942. But after that commit the constant factor increased. This commit reimplements the optimization of eliding unnecessary `packed-refs` rewrites. That, plus the fact that since cfa2e29c34 (packed_ref_store: get rid of the `ref_cache` entirely, 2017-03-17) we don't necessarily have to read the whole `packed-refs` file at all, means that deletes of one or a few loose references can now be done with `O(n lg N)` effort, where `n` is the number of loose references being deleted and `N` is the total number of packed references. This commit fixes two tests in t1409. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-27t1409: check that `packed-refs` is not rewritten unnecessarilyLibravatar Michael Haggerty1-0/+118
There is no need to rewrite the `packed-refs` file except for the case that we are deleting a reference that has a packed version. Verify that `packed-refs` is not rewritten when it shouldn't be. In fact, two of these tests fail: * A new (empty) `packed-refs` file is created when deleting any loose reference and no `packed-refs` file previously existed. * The `packed-refs` file is rewritten unnecessarily when deleting a loose reference that has no packed counterpart. Both problems will be fixed in the next commit. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>