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

[PATCH] gitignore: warn about pointless syntax

From
JEJan Engelhardt <jengelh@medozas.de>
Date
Jan 9, 2012, 15:40 UTC
Message-ID
<1326123647-18352-2-git-send-email-jengelh@medozas.de>
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
Previous: Jan EngelhardtNext: Jeff King
Message 2 of 11 in “gitignore warn about ** submission”
  1. Jan EngelhardtJan 9, 2012
  2. gitignore: warn about pointless syntaxJan Engelhardt, Jan 9, 2012
  3. Jeff KingJan 9, 2012
  4. Junio C HamanoJan 9, 2012
  5. Jeff KingJan 9, 2012
  6. Jan EngelhardtJan 10, 2012
  7. Junio C HamanoJan 10, 2012
  8. Jan EngelhardtJan 10, 2012
  9. Jan EngelhardtJan 10, 2012
  10. Thomas RastJan 10, 2012
  11. Jeff KingJan 10, 2012

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.