git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Engelhardt <jengelh@medozas.de>
To: git@vger.kernel.org
Cc: trast@student.ethz.ch
Subject: [PATCH] gitignore: warn about pointless syntax
Date: Mon,  9 Jan 2012 16:40:47 +0100	[thread overview]
Message-ID: <1326123647-18352-2-git-send-email-jengelh@medozas.de> (raw)
In-Reply-To: <1326123647-18352-1-git-send-email-jengelh@medozas.de>

Add a warning to the gitignore parser if it sees "**". Git, using
fnmatch, does not consider the double-asterisk anything special like
rsync/zsh. Remind users of that, since too many seem to be Doing It
Wrong™.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
---
 dir.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/dir.c b/dir.c
index 0a78d00..60f65cb 100644
--- a/dir.c
+++ b/dir.c
@@ -376,6 +376,15 @@ void free_excludes(struct exclude_list *el)
 	el->excludes = NULL;
 }
 
+static inline void check_bogus_wildcard(const char *file, const char *p)
+{
+	if (strstr(p, "**") == NULL)
+		return;
+	warning(_("Pattern \"%s\" from file \"%s\": Double asterisk does not "
+		"have a special meaning and is interpreted just like a single "
+		"asterisk.\n"), file, p);
+}
+
 int add_excludes_from_file_to_list(const char *fname,
 				   const char *base,
 				   int baselen,
@@ -427,6 +436,7 @@ int add_excludes_from_file_to_list(const char *fname,
 		if (buf[i] == '\n') {
 			if (entry != buf + i && entry[0] != '#') {
 				buf[i - (i && buf[i-1] == '\r')] = 0;
+				check_bogus_wildcard(fname, entry);
 				add_exclude(entry, base, baselen, which);
 			}
 			entry = buf + i + 1;
-- 
1.7.7

  reply	other threads:[~2012-01-09 15:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-09 15:40 gitignore warn about ** submission Jan Engelhardt
2012-01-09 15:40 ` Jan Engelhardt [this message]
2012-01-09 16:28   ` [PATCH] gitignore: warn about pointless syntax Jeff King
2012-01-09 19:43     ` Junio C Hamano
2012-01-09 22:33       ` Jeff King
2012-01-10  5:42         ` Jan Engelhardt
2012-01-10  6:01           ` Junio C Hamano
2012-01-10  7:01             ` Jan Engelhardt
2012-01-10  7:02               ` Jan Engelhardt
2012-01-10  9:44           ` Thomas Rast
2012-01-10 18:51           ` Jeff King
  -- strict thread matches above, loose matches on Subject: below --
2012-01-09 11:34 [patch] " Jan Engelhardt
2012-01-09 13:44 ` Thomas Rast

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

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

  git send-email \
    --in-reply-to=1326123647-18352-2-git-send-email-jengelh@medozas.de \
    --to=jengelh@medozas.de \
    --cc=git@vger.kernel.org \
    --cc=trast@student.ethz.ch \
    /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.
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 NNTP newsgroup(s).