Skip to content

Commit 867b520

Browse files
committed
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
2 parents e2ac914 + 5407764 commit 867b520

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

builtin/receive-pack.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,15 @@ static void execute_commands(struct command *commands,
19611961
return;
19621962
}
19631963

1964+
/*
1965+
* If there is no command ready to run, should return directly to destroy
1966+
* temporary data in the quarantine area.
1967+
*/
1968+
for (cmd = commands; cmd && cmd->error_string; cmd = cmd->next)
1969+
; /* nothing */
1970+
if (!cmd)
1971+
return;
1972+
19641973
/*
19651974
* Now we'll start writing out refs, which means the objects need
19661975
* to be in their final positions so that other processes can see them.

t/t5516-fetch-push.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,4 +1821,12 @@ test_expect_success 'refuse fetch to current branch of bare repository worktree'
18211821
git -C bare.git fetch -u .. HEAD:wt
18221822
'
18231823

1824+
test_expect_success 'refuse to push a hidden ref, and make sure do not pollute the repository' '
1825+
mk_empty testrepo &&
1826+
git -C testrepo config receive.hiderefs refs/hidden &&
1827+
git -C testrepo config receive.unpackLimit 1 &&
1828+
test_must_fail git push testrepo HEAD:refs/hidden/foo &&
1829+
test_dir_is_empty testrepo/.git/objects/pack
1830+
'
1831+
18241832
test_done

0 commit comments

Comments
 (0)