From: Jeff King <peff@peff.net>
To: Sitaram Chamarty <sitaramc@gmail.com>
Cc: git@vger.kernel.org
Subject: [PATCH 2/2] give exclude mechanism a debug option
Date: Sat, 7 Feb 2009 01:44:55 -0500 [thread overview]
Message-ID: <20090207064454.GB14906@coredump.intra.peff.net> (raw)
In-Reply-To: <20090207064221.GA14856@coredump.intra.peff.net>
Users can set GIT_DEBUG_IGNORE in the environment to get the
exclusion mechanism to dump to stderr files mentioned in
.gitignore along with the pattern that matched. The output
looks something like:
foo.c: exclude: *.c
This implementation has several shortcomings that make it
unsuitable for inclusion:
1. Doing it as a debug environment variable is hack-ish.
A nicer interface would be a .gitignore equivalent of
"git check-attr".
2. If you ask for "foo/bar", and "foo/" is ignored, the
output will show only "foo: exclude: foo". This is an
artifact of the calling interface: you don't ask "is
foo/bar excluded", but rather while recursing through
"foo/" you ask "should I bother even recursing into
foo?". So the exclusion code never even knows that you
might have cared about foo/bar in the first place.
3. There is no indication of where patterns came from. We
could specify whether it came from the command-line,
from per-directory files, or from another file. But what
is most interesting is the actual _filename_ that it
came from. I.e., something like:
sub/foo.c: exclude: sub/.gitignore: *.c
But that information seems to have been forgotten by
the time we are actually doing excludes.
Signed-off-by: Jeff King <peff@peff.net>
---
In addition to the problems above, this is hardly tested. ;)
dir.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/dir.c b/dir.c
index 0ea81b7..1052496 100644
--- a/dir.c
+++ b/dir.c
@@ -8,6 +8,7 @@
#include "cache.h"
#include "dir.h"
#include "refs.h"
+#include "quote.h"
struct path_simplify {
int len;
@@ -354,6 +355,24 @@ static struct exclude *excluded_1(const char *pathname,
return NULL;
}
+static int debug_ignore(void)
+{
+ static int ignore = -1;
+ if (ignore == -1) {
+ const char *env = getenv("GIT_DEBUG_IGNORE");
+ ignore = env ? git_config_bool("GIT_DEBUG_IGNORE", env) : 0;
+ }
+ return ignore;
+}
+
+static void show_ignore(const char *path, struct exclude *x)
+{
+ quote_c_style(path, NULL, stderr, 0);
+ fprintf(stderr, ": %s: %.*s\n",
+ (x->to_exclude ? "exclude" : "include"),
+ x->patternlen, x->pattern);
+}
+
int excluded(struct dir_struct *dir, const char *pathname, int *dtype_p)
{
int pathlen = strlen(pathname);
@@ -367,6 +386,8 @@ int excluded(struct dir_struct *dir, const char *pathname, int *dtype_p)
dtype_p, &dir->exclude_list[st]);
if (!x)
continue;
+ if (debug_ignore())
+ show_ignore(pathname, x);
switch (x->to_exclude) {
case 0:
return 0;
--
1.6.1.2.552.g1682c.dirty
next prev parent reply other threads:[~2009-02-07 6:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-06 9:38 How to find out which gitignore blocks my git-add Gonzo
2009-02-06 19:33 ` Jeff King
2009-02-07 1:33 ` Sitaram Chamarty
2009-02-07 6:42 ` Jeff King
2009-02-07 6:44 ` [PATCH 1/2] refactor exclude handling Jeff King
2009-02-07 6:44 ` Jeff King [this message]
2009-02-07 7:38 ` [PATCH 2/2] give exclude mechanism a debug option Junio C Hamano
2009-02-07 7:42 ` Junio C Hamano
2009-02-07 11:46 ` Jeff King
2009-02-07 11:44 ` Jeff King
2009-02-07 21:45 ` Junio C Hamano
2009-02-08 8:59 ` Jeff King
2009-02-08 9:50 ` Junio C Hamano
2009-02-08 9:52 ` Jeff King
2009-02-07 12:44 ` How to find out which gitignore blocks my git-add Sitaram Chamarty
2009-02-07 13:31 ` Jeff King
2009-02-06 22:00 ` Bisani, Alok
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=20090207064454.GB14906@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=sitaramc@gmail.com \
/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).