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

Re: [PATCH] git clean: Don't automatically remove directories when run within subdirectory

From
JHJoachim Berdal Haga <cjbhaga@broadpark.no>
Date
Apr 14, 2008, 18:18 UTC
Message-ID
<48039FE5.5060309@broadpark.no>
In-Reply-To
<20080414170643.GA10548@mediacenter>
Shawn Bohrer wrote:
Show 5 quoted lines
> Agreed I'll send an updated patch later tonight.  One additional thought
> though.  2 is MATCHED_FNMATCH which worries me a little because I think
> this would mean 'git clean -f *' will also remove directories (I haven't
> tried though).  Perhaps this should really be 3 MATCHED_EXACTLY just to
> be safe.  Does anyone have opinions either way?

I don't have strong opinions on this since I don't use this form of the command, but still:

I think that the best option would be to never remove a directory, even if
given explicitly, unless -d is given. Because my gut feeling is that when a
directory name is specified, it is most often meant as "clean inside the
given directory", ie. as a path delimiter. Indeed, if the directory has
tracked files inside of it,
  git clean dir
and
  git clean dir/
have the same effect. If there are no tracked files inside, the current
patch gives the path-delimiting effect on this form
  git clean dir/
but removes the whole directory irrespective of "-d" for this form
  git clean dir
I think that a "honor (lack of) -d even if pathspec matches" would reduce
the consequences of this particular kind of user error (by deleting too
little instead of too much).
-j.
Previous: Shawn BohrerNext: Shawn Bohrer
Message 9 of 14 in “git clean removes directories when not asked to”
  1. Joachim B HagaApr 8, 2008
  2. Joachim B HagaApr 8, 2008
  3. Re: git clean removes directories when not asked toJoachim B Haga, Apr 9, 2008
  4. git clean: Don't automatically remove directories when run within subdirectoryShawn Bohrer, Apr 13, 2008
  5. git clean: Add test to verify directories aren't removed with a prefixShawn Bohrer, Apr 13, 2008
  6. Joachim Berdal HagaApr 14, 2008
  7. Junio C HamanoApr 14, 2008
  8. Shawn BohrerApr 14, 2008
  9. Joachim Berdal HagaApr 14, 2008
  10. Shawn BohrerApr 15, 2008
  11. Joachim Berdal HagaApr 15, 2008
  12. Shawn BohrerApr 15, 2008
  13. Joachim Berdal HagaApr 15, 2008
  14. git clean: Don't automatically remove directories when run within subdirectoryShawn Bohrer, Apr 15, 2008

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.