Merge branch 'js/sequencer-release-odb-before-commit'

The sequencer has been updated to release the object database before
spawning 'git commit'.  This prevents open file handles from
blocking auto-maintenance tasks, such as repacking, on systems like
Windows where open files cannot be easily unlinked.

* js/sequencer-release-odb-before-commit:
  sequencer: release the ODB before spawning git commit
main
Junio C Hamano 2026-08-23 18:01:45 -07:00
commit e8e7bf97fe
2 changed files with 19 additions and 0 deletions

View File

@ -1127,6 +1127,7 @@ static int run_git_commit(const char *defmsg,
struct child_process cmd = CHILD_PROCESS_INIT;

cmd.git_cmd = 1;
cmd.odb_to_close = the_repository->objects;

if (is_rebase_i(opts) &&
((opts->committer_date_is_author_date && !opts->ignore_date) ||

View File

@ -65,6 +65,24 @@ test_expect_success 'setup' '
test_commit P fileP
'

test_expect_success MINGW 'rebase releases object database before committing' '
test_when_finished "rm -f .git/hooks/post-commit repacked packs" &&
git switch -C repack-rewrite primary &&
git repack -ad &&
write_script .git/hooks/post-commit <<-\EOF &&
git repack -ad &&
>repacked
EOF
(
set_fake_editor &&
FAKE_LINES="reword 1" GIT_TEST_LEGACY_DELETE=1 \
git -c core.commitGraph=false rebase -i HEAD^
) &&
test_path_is_file repacked &&
ls .git/objects/pack/*.pack >packs &&
test_line_count = 1 packs
'

# "exec" commands are run with the user shell by default, but this may
# be non-POSIX. For example, if SHELL=zsh then ">file" doesn't work
# to create a file. Unsetting SHELL avoids such non-portable behavior