git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Pete Wyckoff <pw@padd.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Todd Rinaldo <toddr@cpanel.net>
Subject: Re: Re* git clean --exclude broken?
Date: Sat, 27 Aug 2011 19:54:58 -0400	[thread overview]
Message-ID: <20110827235458.GA8124@arf.padd.com> (raw)
In-Reply-To: <7vpqjtl4yi.fsf_-_@alter.siamese.dyndns.org>

gitster@pobox.com wrote on Thu, 25 Aug 2011 11:29 -0700:
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > The documentation and the implementation of "git clean" is quite confused.
> > ...
> 
> So here is a patch to fix the confusion.
> 
> It does not add a new "--except=C" I alluded to, but at least it should
> be the right first step to make the document clearly describe what the
> existing option does.
> 
> -- >8 --
> Subject: [PATCH] Documentation: clarify "git clean -e <pattern>"
> 
> The current explanation of -e can be misread as allowing the user to say
> 
>     I know 'git clean -XYZ' (substitute -XYZ with any option and/or
>     parameter) will remove paths A, B, and C, and I want them all removed
>     except for paths matching this pattern by adding '-e C' to the same
>     command line, i.e. 'git clean -e C -XYZ'.
> 
> But that is not what this option does. It augments the set of ignore rules
> from the command line, just like the same "-e <pattern>" argument does
> with the "ls-files" command (the user could probably pass "-e \!C" to tell
> the command to clean everything the command would normally remove, except
> for C).
> 
> It also fixes small style nit in the parameter to add_exclude() call. The
> current code only works because EXC_CMDL happens to be defined as 0.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  Documentation/git-clean.txt |    6 +++---
>  builtin/clean.c             |    5 ++++-
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/git-clean.txt b/Documentation/git-clean.txt
> index 974e04e..a7a18e3 100644
> --- a/Documentation/git-clean.txt
> +++ b/Documentation/git-clean.txt
> @@ -47,9 +47,9 @@ OPTIONS
>  
>  -e <pattern>::
>  --exclude=<pattern>::
> -	Specify special exceptions to not be cleaned.  Each <pattern> is
> -	the same form as in $GIT_DIR/info/excludes and this option can be
> -	given multiple times.
> +	In addition to what are found in .gitignore (per directory) and
> +	$GIT_DIR/info/exclude, also consider these patterns to be in the
> +	set of the ignore rules in effect.
>  
>  -x::
>  	Don't use the ignore rules.  This allows removing all untracked
> diff --git a/builtin/clean.c b/builtin/clean.c
> index 75697f7..3782718 100644
> --- a/builtin/clean.c
> +++ b/builtin/clean.c
> @@ -76,6 +76,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
>  
>  	if (ignored && ignored_only)
>  		die(_("-x and -X cannot be used together"));
> +	if (ignored && exclude_list.nr)
> +		die(_("adding exclude with -e and ignoring it with -x is crazy"));

This breaks one of my use cases for git clean.

We have "precious" files that are listed in .gitignore so that
they don't show up in "git status" output.  They're not part of
the repository, but special per-user per-workspace configuration
settings that are required to build the code.

There's plenty of other stuff in .gitignore that should be
deleted.  So we invoke:

    git clean -dqfx -e .magic_file -e "Magic*"

It's been discussed on the list a couple of times that a separate
category for files that I want to ignore, but do not want to
have cleaned, would fill this gap.

		-- Pete

>  	if (!show_only && !force) {
>  		if (config_set)
> @@ -98,7 +100,8 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
>  		setup_standard_excludes(&dir);
>  
>  	for (i = 0; i < exclude_list.nr; i++)
> -		add_exclude(exclude_list.items[i].string, "", 0, dir.exclude_list);
> +		add_exclude(exclude_list.items[i].string, "", 0,
> +			    &dir.exclude_list[EXC_CMDL]);
>  
>  	pathspec = get_pathspec(prefix, argv);
>  
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  parent reply	other threads:[~2011-08-27 23:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-24 19:15 git clean --exclude broken? Todd Rinaldo
2011-08-24 21:23 ` Junio C Hamano
2011-08-24 23:08   ` Todd Rinaldo
2011-08-25  1:38   ` Junio C Hamano
2011-08-25 18:29     ` Re* " Junio C Hamano
2011-08-25 18:38       ` Michael Schubert
2011-08-25 20:28         ` Junio C Hamano
2011-08-26 10:00       ` Thomas Rast
2011-08-27 23:54       ` Pete Wyckoff [this message]
2011-08-28  6:27         ` Junio C Hamano
2011-08-28 12:31           ` Pete Wyckoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110827235458.GA8124@arf.padd.com \
    --to=pw@padd.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=toddr@cpanel.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).