# [patch] gitignore: warn about pointless syntax

2 messages from 2012-01-09 to 2012-01-09. Participants: Jan Engelhardt, Thomas Rast.
Thread: https://gitlist.dev/t/29319

## Jan Engelhardt, 2012-01-09 11:34

Subject: [patch] gitignore: warn about pointless syntax
Message-ID: <alpine.LNX.2.01.1201091233050.28805@frira.zrqbmnf.qr>
URL: https://gitlist.dev/e/alpine.LNX.2.01.1201091233050.28805%40frira.zrqbmnf.qr

```
parent eac2d83247ea0a265d923518c26873bb12c33778 (v1.7.9-rc0)
commit b629bde461aeb178b257ab7e0f6c180f69f98cb0
Author: Jan Engelhardt <jengelh@medozas.de>
Date:   Mon Jan 9 12:30:07 2012 +0100

gitignore: warn about pointless syntax

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;
-- 
# Created with git-export-patch

```

## Thomas Rast, 2012-01-09 13:44

Subject: Re: [patch] gitignore: warn about pointless syntax
Message-ID: <87vcolrnw2.fsf@thomas.inf.ethz.ch>
URL: https://gitlist.dev/e/87vcolrnw2.fsf%40thomas.inf.ethz.ch
In-Reply-To: <alpine.LNX.2.01.1201091233050.28805@frira.zrqbmnf.qr>

```
Jan Engelhardt <jengelh@medozas.de> writes:

> parent eac2d83247ea0a265d923518c26873bb12c33778 (v1.7.9-rc0)
> commit b629bde461aeb178b257ab7e0f6c180f69f98cb0
> Author: Jan Engelhardt <jengelh@medozas.de>
> Date:   Mon Jan 9 12:30:07 2012 +0100
>
> gitignore: warn about pointless syntax
[...]
> -- 
> # Created with git-export-patch

Are you the author of this tool?  The format is bogus in so far as it
causes git-am to insert the above lines into the git commit message, as
in:

    $ git am -3 < gitignore-patch.mbox
    Applying: gitignore: warn about pointless syntax
    $ git show
    commit 59bea4d9a1de3b3b9c0139de4298ffd9d9431457
    Author: Jan Engelhardt <jengelh@medozas.de>
    Date:   Mon Jan 9 12:34:12 2012 +0100

        gitignore: warn about pointless syntax
        
        parent eac2d83247ea0a265d923518c26873bb12c33778 (v1.7.9-rc0)
        commit b629bde461aeb178b257ab7e0f6c180f69f98cb0
        Author: Jan Engelhardt <jengelh@medozas.de>
        Date:   Mon Jan 9 12:30:07 2012 +0100
        
        gitignore: warn about pointless syntax
    [...]

So using this tool over format-patch is just a pointless cause of manual
fixup work.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

```
