Download raw body.
leading separators in ignore patterns
On Mon, May 19, 2025 at 11:03:49AM -0700, Evan Silberman wrote: > 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. This looks like a small mistake in Git to me. For all intents and purposes, // is the same as / in a path. For edge cases like this, I'd rather have Got behave intuitively than replicate Git's mistakes. Anyway, I'll commit your patch as it is for now, and then think about adding my tweak on top.
leading separators in ignore patterns