Merge branch 'ma/maintenance-crontab-fix'

Hotfix for a topic of this cycle.

* ma/maintenance-crontab-fix:
  t7900-maintenance: test for magic markers
  gc: fix handling of crontab magic markers
  git-maintenance.txt: add missing word
This commit is contained in:
Junio C Hamano 2020-12-23 13:59:46 -08:00
commit 7a50265295
3 changed files with 20 additions and 5 deletions

View File

@ -101,7 +101,7 @@ This is done to avoid disrupting the remote-tracking branches. The end users
expect these refs to stay unmoved unless they initiate a fetch. With prefetch expect these refs to stay unmoved unless they initiate a fetch. With prefetch
task, however, the objects necessary to complete a later real fetch would task, however, the objects necessary to complete a later real fetch would
already be obtained, so the real fetch would go faster. In the ideal case, already be obtained, so the real fetch would go faster. In the ideal case,
it will just become an update to bunch of remote-tracking branches without it will just become an update to a bunch of remote-tracking branches without
any object transfer. any object transfer.
gc:: gc::

View File

@ -1554,11 +1554,10 @@ static int update_background_schedule(int run_maintenance)
while (!strbuf_getline_lf(&line, cron_list)) { while (!strbuf_getline_lf(&line, cron_list)) {
if (!in_old_region && !strcmp(line.buf, BEGIN_LINE)) if (!in_old_region && !strcmp(line.buf, BEGIN_LINE))
in_old_region = 1; in_old_region = 1;
if (in_old_region) else if (in_old_region && !strcmp(line.buf, END_LINE))
continue;
fprintf(cron_in, "%s\n", line.buf);
if (in_old_region && !strcmp(line.buf, END_LINE))
in_old_region = 0; in_old_region = 0;
else if (!in_old_region)
fprintf(cron_in, "%s\n", line.buf);
} }
if (run_maintenance) { if (run_maintenance) {

View File

@ -446,6 +446,22 @@ test_expect_success 'start preserves existing schedule' '
grep "Important information!" cron.txt grep "Important information!" cron.txt
' '
test_expect_success 'magic markers are correct' '
grep "GIT MAINTENANCE SCHEDULE" cron.txt >actual &&
cat >expect <<-\EOF &&
# BEGIN GIT MAINTENANCE SCHEDULE
# END GIT MAINTENANCE SCHEDULE
EOF
test_cmp actual expect
'
test_expect_success 'stop preserves surrounding schedule' '
echo "Crucial information!" >>cron.txt &&
GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance stop &&
grep "Important information!" cron.txt &&
grep "Crucial information!" cron.txt
'
test_expect_success 'register preserves existing strategy' ' test_expect_success 'register preserves existing strategy' '
git config maintenance.strategy none && git config maintenance.strategy none &&
git maintenance register && git maintenance register &&