public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH 0/3] clean: add `config.exclude` and `--remove-excluded`
@ 2025-02-10 19:14 Ivan Shapovalov
  2025-02-10 19:14 ` [PATCH 1/3] clean, dir: add and use new helper `add_patterns_from_string_list()` Ivan Shapovalov
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Ivan Shapovalov @ 2025-02-10 19:14 UTC (permalink / raw)
  To: git; +Cc: Ivan Shapovalov, Ævar Arnfjörð Bjarmason,
	Junio C Hamano

This series extends the concept of "excluded files" in `git clean` to
make it useful to protect "precious files" that might be present in a
specific developer's working tree (see below).

Specifically, this series adds a `config.exclude` knob to configure
"always excluded" files (same as `-e` on the command line), and a
`--remove-excluded` flag (intentionally without a short form) to
"REALLY remove everything, dammit!"

This might seem like euphemism treadmill, but there is a specific
use-case for all of the exclusion methods and options:

.gitignore:     files that _the project_ does not want to track or touch
                (build artifacts)
clean.exclude:  files that _the user_ does not want to track or touch
                (IDE configuration)
git clean -x:   remove build artifacts, but keep precious files
                (when a pristine build is desired)
git clean -x --remove-excluded:
                remove everything, including precious files
                (e.g. for redistribution)

For instance, if I use Sublime Text or JetBrains IDEs to work on
projects, I might want to add this to my ~/.gitconfig:

[clean]
  exclude = /*.sublime-*
  exclude = /.idea

Or, if I make use of the Bear compiler wrapper to generate the
compilation database in those projects that do not use any of the
modern build-systems to automate such generation, I might write:

[clean]
  exclude = /compile_commands.json

This way, even if I run `git clean -fxd` to test a clean build, I do
not need to worry about accidentally removing the compilation database
that would take a bunch of CPU-time to regenerate.

Ivan Shapovalov (3):
  clean, dir: add and use new helper `add_patterns_from_string_list()`
  clean: rename `ignored` -> `remove_ignored`
  clean: add `config.exclude` and `--remove-excluded`

 Documentation/config/clean.txt | 11 +++++++++++
 Documentation/git-clean.txt    | 22 +++++++++++++++-------
 builtin/clean.c                | 32 +++++++++++++++++++++-----------
 dir.c                          | 15 +++++++++++++++
 dir.h                          |  4 ++++
 5 files changed, 66 insertions(+), 18 deletions(-)

-- 
2.48.1.5.g9188e14f140


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-02-11 23:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-10 19:14 [PATCH 0/3] clean: add `config.exclude` and `--remove-excluded` Ivan Shapovalov
2025-02-10 19:14 ` [PATCH 1/3] clean, dir: add and use new helper `add_patterns_from_string_list()` Ivan Shapovalov
2025-02-10 19:14 ` [PATCH 2/3] clean: rename `ignored` -> `remove_ignored` Ivan Shapovalov
2025-02-10 19:14 ` [PATCH 3/3] clean: add `config.exclude` and `--remove-excluded` Ivan Shapovalov
2025-02-11 23:00   ` Junio C Hamano
2025-02-11 18:37 ` [PATCH 0/3] " Junio C Hamano
2025-02-11 18:47   ` Ivan Shapovalov
2025-02-11 21:24     ` Junio C Hamano
2025-02-11 21:42       ` Ivan Shapovalov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox