Merge branch 'cb/clear-quarantine-early-on-all-ref-update-errors'

"receive-pack" checks if it will do any ref updates (various
conditions could reject a push) before received objects are taken
out of the temporary directory used for quarantine purposes, so
that a push that is known-to-fail will not leave crufts that a
future "gc" needs to clean up.

* cb/clear-quarantine-early-on-all-ref-update-errors:
  receive-pack: purge temporary data if no command is ready to run
This commit is contained in:
Junio C Hamano 2022-02-18 13:53:27 -08:00
Родитель e2ac9141e6 5407764069
Коммит 867b520301
2 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -1961,6 +1961,15 @@ static void execute_commands(struct command *commands,
return;
}
/*
* If there is no command ready to run, should return directly to destroy
* temporary data in the quarantine area.
*/
for (cmd = commands; cmd && cmd->error_string; cmd = cmd->next)
; /* nothing */
if (!cmd)
return;
/*
* Now we'll start writing out refs, which means the objects need
* to be in their final positions so that other processes can see them.

Просмотреть файл

@ -1821,4 +1821,12 @@ test_expect_success 'refuse fetch to current branch of bare repository worktree'
git -C bare.git fetch -u .. HEAD:wt
'
test_expect_success 'refuse to push a hidden ref, and make sure do not pollute the repository' '
mk_empty testrepo &&
git -C testrepo config receive.hiderefs refs/hidden &&
git -C testrepo config receive.unpackLimit 1 &&
test_must_fail git push testrepo HEAD:refs/hidden/foo &&
test_dir_is_empty testrepo/.git/objects/pack
'
test_done