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

Re: git rm bug?

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 30, 2013, 19:01 UTC
Message-ID
<xmqqob66bn2f.fsf@gitster.dls.corp.google.com>
In-Reply-To
<155154AA-15E8-49E8-8261-6295AC6F6CF7@csail.mit.edu>
Eunsuk Kang <eskang@csail.mit.edu> writes:
> My understanding was that running "git rm" on a file will delete
> all ancestors of the file that are empty directories from the file
> system.
Not really.

We do recurse up to see if a/b/ and then a/ has become a useless empty directory when we did remove a/b/c from the working tree, but when we did not have to remove a/b/c (because you have already removed it), we assume that you know what you are doing and do nothing to the leading directories.

This behaviour is not because we suspect that you might want to retain a/ or a/b/; it is just we do not even bother. So it is entirely plausible that a patch to actually bother checking the leading directories to see if they have become or they already were empty directories and remove them, if done cleanly, may be a welcome change. At least, that would make things consistent between the cases where you have already manually removed the file a/b/c on the working tree and where the command removed in response to your direct request to remove the same file a/b/c.

Previous: Eunsuk Kang
Message 2 of 2 in “git rm bug?”
  1. Eunsuk KangOct 30, 2013
  2. Junio C HamanoOct 30, 2013

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.