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

Re: [RFC] git clean --local

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 4, 2018, 02:45 UTC
Message-ID
<xmqqk1kqf1r4.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<xmqqk1kriuu8.fsf@gitster-ct.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 8 quoted lines
> If "git clean" takes a pathspec, perhaps you can give a negative
> pathspec to exclude whatever you do not want to get cleaned,
> something like
>
> 	git clean '*.o' ':!precious.o'
>
> to say "presious.o is ignored (hence normally expendable), but I do
> not want to clean it with this invocation of 'git clean'"?

Hmph, this leads me to an interesting thought. With today's code, these two commands behave in meaningfully different ways when I mark some paths that match .gitignore patterns with the precious attribute.

	echo "*.ignored" >>.git/info/exclude
	echo "precious.* precious" >>.git/info/attributes
	: >expendable.ignored 2>precious.ignored
	git clean -n -x
	git clean -n -x ':(exclude,attr:precious)'

I am not suggesting that giving "git clean" a configuration knob that always append pathspec elements, which would allow users to use the mechanism to set the above magic pathspec, would be a good approach. If we were to follow through this line of thought, an obvious thing to do is to always unconditonally append the above magic pathspec internally when running "git clean", which would mean

 * Existing projects and users' repositories will see no behaviour
   change, because they are unaware of the "precious" attribute.
 * People who learn the new feature can start using the "ignored but
   precious" class, without any need for transition period.
Previous: Cameron Boehmer
Message 8 of 8 in “[RFC] git clean --local”
  1. Cameron BoehmerDec 1, 2018
  2. Junio C HamanoDec 2, 2018
  3. Junio C HamanoDec 2, 2018
  4. Ævar Arnfjörð BjarmasonDec 2, 2018
  5. Randall S. BeckerDec 2, 2018
  6. Junio C HamanoDec 2, 2018
  7. Cameron BoehmerDec 3, 2018
  8. Junio C HamanoDec 4, 2018

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.