You get a nasty error like: $ git push origin -d refs/users/redi/heads/calendar remote: *** Update rejected by this repository's hooks.update-hook script remote: *** (/git/gcc.git/hooks-bin/update_hook): remote: *** fatal: bad object 0000000000000000000000000000000000000000 remote: *** Traceback (most recent call last): remote: *** File "/git/gcc.git/hooks-bin/update_hook", line 39, in <module> remote: *** main() remote: *** File "/git/gcc.git/hooks-bin/update_hook", line 27, in main remote: *** check=True, universal_newlines=True).stdout.split('\n') remote: *** File "/usr/lib64/python3.6/subprocess.py", line 438, in run remote: *** output=stdout, stderr=stderr) remote: *** subprocess.CalledProcessError: Command '['git', 'rev-list', '0000000000000000000000000000000000000000', '^4415a3e0965ae6e2a4bedd3584b2504ebb2d96f3']' returned non-zero exit status 128. remote: error: hook declined to update refs/users/redi/heads/calendar To git+ssh://gcc.gnu.org/git/gcc.git ! [remote rejected] refs/users/redi/heads/calendar (hook declined) error: failed to push some refs to 'git+ssh://gcc.gnu.org/git/gcc.git'
The problem is that the script doesn't check whether the new_object is 000000000. I think we want something like this: --- update_hook 2020-09-02 23:30:25.074884982 +0000 +++ /tmp/update_hook 2020-10-01 13:57:14.681656258 +0000 @@ -12,6 +12,12 @@ ref_name = sys.argv[1] old_object = sys.argv[2] new_object = sys.argv[3] + if re.fullmatch('0+', new_object) is not None: + if (not ref_name.startswith('refs/users/') + and not ref_name.startswith('refs/vendors/')): + error('Only personal and vendor branches can be deleted.') + sys.exit(1) + sys.exit(0) # Do not allow updates introducing ancestry based on the old # git-svn repository, to ensure people rebase onto the new history # rather than merging branches based on git-svn history into those