Skip to content

Commit 7a50265

Browse files
committed
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
2 parents 04cd999 + a52df25 commit 7a50265

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

Documentation/git-maintenance.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ This is done to avoid disrupting the remote-tracking branches. The end users
101101
expect these refs to stay unmoved unless they initiate a fetch. With prefetch
102102
task, however, the objects necessary to complete a later real fetch would
103103
already be obtained, so the real fetch would go faster. In the ideal case,
104-
it will just become an update to bunch of remote-tracking branches without
104+
it will just become an update to a bunch of remote-tracking branches without
105105
any object transfer.
106106

107107
gc::

builtin/gc.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,11 +1554,10 @@ static int update_background_schedule(int run_maintenance)
15541554
while (!strbuf_getline_lf(&line, cron_list)) {
15551555
if (!in_old_region && !strcmp(line.buf, BEGIN_LINE))
15561556
in_old_region = 1;
1557-
if (in_old_region)
1558-
continue;
1559-
fprintf(cron_in, "%s\n", line.buf);
1560-
if (in_old_region && !strcmp(line.buf, END_LINE))
1557+
else if (in_old_region && !strcmp(line.buf, END_LINE))
15611558
in_old_region = 0;
1559+
else if (!in_old_region)
1560+
fprintf(cron_in, "%s\n", line.buf);
15621561
}
15631562

15641563
if (run_maintenance) {

t/t7900-maintenance.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,22 @@ test_expect_success 'start preserves existing schedule' '
446446
grep "Important information!" cron.txt
447447
'
448448

449+
test_expect_success 'magic markers are correct' '
450+
grep "GIT MAINTENANCE SCHEDULE" cron.txt >actual &&
451+
cat >expect <<-\EOF &&
452+
# BEGIN GIT MAINTENANCE SCHEDULE
453+
# END GIT MAINTENANCE SCHEDULE
454+
EOF
455+
test_cmp actual expect
456+
'
457+
458+
test_expect_success 'stop preserves surrounding schedule' '
459+
echo "Crucial information!" >>cron.txt &&
460+
GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance stop &&
461+
grep "Important information!" cron.txt &&
462+
grep "Crucial information!" cron.txt
463+
'
464+
449465
test_expect_success 'register preserves existing strategy' '
450466
git config maintenance.strategy none &&
451467
git maintenance register &&

0 commit comments

Comments
 (0)