Download raw body.
leading separators in ignore patterns
On Wed, May 21, 2025 at 02:57:47PM -0700, Evan Silberman wrote: > realizing now my commit message refers to gitignore(7) but it's actually > gitignore(5)...that'll bother me forever now That happens every now and then :) > > 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. > > I thought perhaps what gitignore(5) says would cut against this but on > taking another look I don't think it actually does. At best it's > unspecified. I propose this: diff /home/stsp/src/got path + /home/stsp/src/got commit - 6ae2855c45508b25adb202d57dd345da8500b7bb blob - 4e690714aa90a9b5159147f65bf8292f5ed4c327 file + lib/worktree.c --- lib/worktree.c +++ lib/worktree.c @@ -3817,9 +3817,9 @@ match_path(const char *pattern, size_t pattern_len, co size_t len = pattern_len; /* - * For gitignore(7) compatibility, ignore leading slashes + * For gitignore(5) compatibility, ignore leading slashes. */ - if (len > 0 && pat[0] == '/') { + while (len > 0 && pat[0] == '/') { pat++; len--; } commit - 6ae2855c45508b25adb202d57dd345da8500b7bb blob - 5e57f89a8f3c5c4f999f1f0bd918335e63d74fb7 file + regress/cmdline/status.sh --- regress/cmdline/status.sh +++ regress/cmdline/status.sh @@ -736,7 +736,7 @@ test_status_gitignore_leading_slashes() { echo "unversioned file" > $testroot/wt/epsilon/nu/baz echo "/foo" > $testroot/wt/.gitignore - echo "/nu" >> $testroot/wt/.gitignore + echo "//////////////////////////nu" >> $testroot/wt/.gitignore echo '? .gitignore' > $testroot/stdout.expected echo '? epsilon/bar' >> $testroot/stdout.expected
leading separators in ignore patterns