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

Re: BUG: git clean -d cannot remove files from read-only directories

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 20, 2020, 18:32 UTC
Message-ID
<xmqqo8ttaz3p.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<BL0PR2101MB10898F2F84B06B1A6B23228380130@BL0PR2101MB1089.namprd21.prod.outlook.com>
Adam Milazzo <Adam.Milazzo@microsoft.com> writes:
Show 14 quoted lines
> Repro steps:
> 1. git init 
> 2. mkdir d
> 3. touch d/a
> 4. chmod -w d
> 5. git clean -fd
>
> Actual result:
> Git doesn't remove anything, saying "warning: failed to remove d/a".
>
> Expected result:
> Git should remove the subdirectory 'd' along with its
> contents. Note that git can remove a read-only file (touch b;
> chmod -w b; git clean -f) with no problem.
It is how UNIX-like filesystem works, isn't it?

As long as a directory D is writable/executable, any regular file inside it can be removed regardless of the perm-bits of the file.

	mkdir d
	touch d/a
	chmod -w d
	rm d/a

would not let you remove the file d/a from d/, exactly because you cannot modify d/ (it is not writable).

Previous: Adam MilazzoNext: Junio C Hamano
Message 2 of 5 in “BUG: git clean -d cannot remove files from read-only directories”
  1. Adam MilazzoFeb 20, 2020
  2. Junio C HamanoFeb 20, 2020
  3. Junio C HamanoFeb 20, 2020
  4. Daniel Knittl-FrankFeb 20, 2020
  5. brian m. carlsonFeb 21, 2020

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.