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

Re: Bug: Branch Deletion Doesn't Clean Up

From
Jeff King <peff@peff.net>
Date
Feb 4, 2016, 07:54 UTC
Message-ID
<20160204075402.GA21112@sigill.intra.peff.net>
In-Reply-To
<4AC354E1-9E78-42A8-9828-BF1C084A6CBB@me.com>
On Thu, Jan 07, 2016 at 02:24:41PM -0500, Karl Moskowski wrote:
> The problem is, deleting a branch whose name contains slashes doesn’t
> delete the directories in .git/refs/heads/.

Yes. Git's model is to leave the directories in place, and remove them only when they get in the way of creating another ref. In theory, the effect is the same as deleting the directories proactively.

But as you noticed, it does funny things with case-preserving filesystems. It also can cause performance problems if you have a very large number of empty directories (because git has to open each of them just to find out they're empty).

We can into the latter case at GitHub. Michael Haggerty (cc'd) worked up some patches recently for this, but I don't now if they're yet polished enough to send upstream.

> It seems like git branch -d ascend the hierarchy (up to
> .git/refs/heads/), deleting any empty directories.

Yes, though it needs to be coupled with making the branch-creation process more robust to races (since we might create "refs/heads/foo" in order to make "refs/heads/foo/bar" while somebody else is deleting it to get rid of "refs/heads/foo/baz").

-Peff
Previous: Karl MoskowskiNext: Jeff King
Message 2 of 7 in “Bug: Branch Deletion Doesn't Clean Up”
  1. Karl MoskowskiJan 7, 2016
  2. Jeff KingFeb 4, 2016
  3. Jeff KingFeb 4, 2016
  4. Mike HommeyFeb 4, 2016
  5. Jeff KingFeb 4, 2016
  6. Mike HommeyFeb 4, 2016
  7. Jeff KingFeb 4, 2016

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.