summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-07-31 20:51:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-07-31 20:51:05 (GMT)
commit133578a020ac5449d36cea741cfc1e7acd7f93a8 (patch)
treed1594e7add0085de89c382e7b1567c16d13d3583 /t
parent309ff914d5ae1cdc95c826f7ac45b859e1d43d67 (diff)
parentc45af94dbc960cbb46ac482ec9cb7f73f55ea270 (diff)
downloadgit-133578a020ac5449d36cea741cfc1e7acd7f93a8.zip
git-133578a020ac5449d36cea741cfc1e7acd7f93a8.tar.gz
git-133578a020ac5449d36cea741cfc1e7acd7f93a8.tar.bz2
Merge branch 'jk/gc-pre-detach-under-hook' into maint
We run an early part of "git gc" that deals with refs before daemonising (and not under lock) even when running a background auto-gc, which caused multiple gc processes attempting to run the early part at the same time. This is now prevented by running the early part also under the GC lock. * jk/gc-pre-detach-under-hook: gc: run pre-detach operations under lock
Diffstat (limited to 't')
-rwxr-xr-xt/t6500-gc.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
index cc7acd1..41b0be5 100755
--- a/t/t6500-gc.sh
+++ b/t/t6500-gc.sh
@@ -95,6 +95,27 @@ test_expect_success 'background auto gc does not run if gc.log is present and re
test_line_count = 1 packs
'
+test_expect_success 'background auto gc respects lock for all operations' '
+ # make sure we run a background auto-gc
+ test_commit make-pack &&
+ git repack &&
+ test_config gc.autopacklimit 1 &&
+ test_config gc.autodetach true &&
+
+ # create a ref whose loose presence we can use to detect a pack-refs run
+ git update-ref refs/heads/should-be-loose HEAD &&
+ test_path_is_file .git/refs/heads/should-be-loose &&
+
+ # now fake a concurrent gc that holds the lock; we can use our
+ # shell pid so that it looks valid.
+ hostname=$(hostname || echo unknown) &&
+ printf "$$ %s" "$hostname" >.git/gc.pid &&
+
+ # our gc should exit zero without doing anything
+ run_and_wait_for_auto_gc &&
+ test_path_is_file .git/refs/heads/should-be-loose
+'
+
# DO NOT leave a detached auto gc process running near the end of the
# test script: it can run long enough in the background to racily
# interfere with the cleanup in 'test_done'.