git/list[1] front-page[2] threads[3] people[4] search[5] about
 

bug: update hook failure doesn't prevent local deletion of a branch

From
APAndy Parkins <andyparkins@gmail.com>
Date
Jul 25, 2007, 11:50 UTC
Message-ID
<200707251250.08166.andyparkins@gmail.com>
Hello,

I wanted to delete a branch (let's call it "deleted-branch") from my public repository. I ran this:

$ git push origin :deleted-branch
deleting 'refs/heads/deleted-branch'
 Also local refs/remotes/up/deleted-branch
*** Update hook: aborting
error: hooks/update exited with error code 1
error: hook declined to update refs/heads/deleted-branch
ng refs/heads/deleted-branch hook declined
error: failed to push to '/path/to/git/repo.git'

Coincidentally, my update hook happened to have a bug in it that prevented me from running the operation.

However, when I run the operation again...
$ git push origin :deleted-branch
deleting 'refs/heads/deleted-branch'
 Also local refs/remotes/up/deleted-branch
error: unlink(.git/refs/remotes/up/deleted-branch) failed: No such file or 
directory
error: Failed to delete

If the remote didn't get deleted, then it seems wrong that the local copy does get deleted.

Summary: when using git-push to delete a remote branch, and that deletion is 
disallowed by the update hook, the local tracking branch _is_ deleted.

Obviously, this isn't _that_ serious because it could be recovered again with a git-fetch; but it does make some scary looking errors.

Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Next: Junio C Hamano
Message 1 of 4 in “bug: update hook failure doesn't prevent local deletion of a branch”
  1. Andy ParkinsJul 25, 2007
  2. Junio C HamanoJul 27, 2007
  3. Shawn O. PearceJul 27, 2007
  4. Junio C HamanoJul 27, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.