Skip to content

Commit d702cb9

Browse files
committed
Merge branch 'ds/maintenance-part-3'
"git maintenance" command had trouble working in a directory whose pathname contained an ERE metacharacter like '+'. * ds/maintenance-part-3: maintenance: use 'git config --fixed-value'
2 parents a10e784 + 483a6d9 commit d702cb9

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

builtin/gc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,8 @@ static int maintenance_register(void)
14601460
git_config_set("maintenance.strategy", "incremental");
14611461

14621462
config_get.git_cmd = 1;
1463-
strvec_pushl(&config_get.args, "config", "--global", "--get", "maintenance.repo",
1463+
strvec_pushl(&config_get.args, "config", "--global", "--get",
1464+
"--fixed-value", "maintenance.repo",
14641465
the_repository->worktree ? the_repository->worktree
14651466
: the_repository->gitdir,
14661467
NULL);
@@ -1491,7 +1492,7 @@ static int maintenance_unregister(void)
14911492

14921493
config_unset.git_cmd = 1;
14931494
strvec_pushl(&config_unset.args, "config", "--global", "--unset",
1494-
"maintenance.repo",
1495+
"--fixed-value", "maintenance.repo",
14951496
the_repository->worktree ? the_repository->worktree
14961497
: the_repository->gitdir,
14971498
NULL);

t/t7900-maintenance.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,18 @@ test_expect_success 'register and unregister' '
404404
test_cmp before actual
405405
'
406406

407+
test_expect_success !MINGW 'register and unregister with regex metacharacters' '
408+
META="a+b*c" &&
409+
git init "$META" &&
410+
git -C "$META" maintenance register &&
411+
git config --get-all --show-origin maintenance.repo &&
412+
git config --get-all --global --fixed-value \
413+
maintenance.repo "$(pwd)/$META" &&
414+
git -C "$META" maintenance unregister &&
415+
test_must_fail git config --get-all --global --fixed-value \
416+
maintenance.repo "$(pwd)/$META"
417+
'
418+
407419
test_expect_success 'start from empty cron table' '
408420
GIT_TEST_CRONTAB="test-tool crontab cron.txt" git maintenance start &&
409421

0 commit comments

Comments
 (0)