"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Evan Silberman <evan@jklol.net>
Subject:
Re: leading separators in ignore patterns
To:
Stefan Sperling <stsp@stsp.name>
Cc:
gameoftrees@openbsd.org
Date:
Mon, 19 May 2025 11:03:49 -0700

Download raw body.

Thread
Stefan Sperling <stsp@stsp.name> wrote:
> I have one small suggestion for your patch. In any case, your patch
> looks very good to me.

Thanks!

> 
> >  	/*
> > +	 * For gitignore(7) compatibility, ignore leading slashes
> > +	 */
> > +	if (len > 0 && pat[0] == '/') {
> > +		pat++;
> > +		len--;
> > +	}
> 
> If the above was a while-loop instead of an if-statement then you could
> do the following in your test and the test would keep passing:

It would but that would actually worsen compatibility with gitignore(7),
consider:


asdf $ cat .gitignore
/nu
//iota
asdf $ tree
.
|-- b
|   |-- iota
|   |   `-- a
|   `-- nu
|       `-- a
|-- iota
|   `-- a
`-- nu
    `-- a

5 directories, 4 files
asdf $ git status -s
?? .gitignore
?? b/
?? iota/


So I think we don't want to change that, since git also seems to treat only
the first `/` specially in this way.

Thanks for the feedback, and the encouragement to follow through with
the patch.

E