Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Timofey Vasenin via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Timofey Vasenin <timofey.vasenin@gmail.com>
Subject: Re: [PATCH] gitignore.txt: fix slash-rules example
Date: Tue, 14 May 2024 14:50:41 -0700	[thread overview]
Message-ID: <xmqqseyk2hce.fsf@gitster.g> (raw)
In-Reply-To: <pull.1720.git.git.1715705582609.gitgitgadget@gmail.com> (Timofey Vasenin via GitGitGadget's message of "Tue, 14 May 2024 16:53:02 +0000")

"Timofey Vasenin via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Timofey Vasenin <timofey.vasenin@gmail.com>
>
> Fix an apparent typo, introduced in:
> 1a58bad014 (gitignore.txt: make slash-rules more readable, 2019-06-04)
> ...
> diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
> index 5e0964ef419..7142fa10acc 100644
> --- a/Documentation/gitignore.txt
> +++ b/Documentation/gitignore.txt
> @@ -100,7 +100,7 @@ PATTERN FORMAT
>     will only match directories, otherwise the pattern can match both
>     files and directories.
>  
> - - For example, a pattern `doc/frotz/` matches `doc/frotz` directory,
> + - For example, a pattern `/doc/frotz/` matches `doc/frotz` directory,
>     but not `a/doc/frotz` directory; however `frotz/` matches `frotz`
>     and `a/frotz` that is a directory (all paths are relative from
>     the `.gitignore` file).

Are you sure this is a typo?

The text added by the same commit (taken from "git show 1a58bad014")
has this passage:

+ - The pattern `doc/frotz` and `/doc/frotz` have the same effect
+   in any `.gitignore` file. In other words, a leading slash
+   is not relevant  if there is already a middle slash in
+   the pattern.

So, if your updated /doc/frotz/ works as described (i.e. match
doc/frotz but not a/doc/frotz), then the original doc/frotz/ should
behave exactly the same way, no?  If you have a good reason to believe
that doc/frotz/ described there should be /doc/frotz/ instead, then
you need to also update that "have the same effect" paragraph.

There should already be an existing test that checks it somewhere
under t/; finding one is left as an exercise (or punishment) to
readers ;-).

It is easy to construct a test case from scratch.

    $ mkdir -p doc/frotz/ a/doc/frotz/
    $ >doc/frotz/foo
    $ >a/doc/frotz/bar
    $ echo doc/frotz >.gitignore
    $ git check-ignore -v doc/frotz/foo a/doc/frotz/bar
    .gitignore:1:doc/frotz	doc/frotz/foo

It seems that doc/frotz seems to work exactly as described, matching
with doc/frotz/foo but not with a/doc/frotz/bar, without a leading
slash, thanks to a slash in the middle.

So...


      reply	other threads:[~2024-05-14 21:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 16:53 [PATCH] gitignore.txt: fix slash-rules example Timofey Vasenin via GitGitGadget
2024-05-14 21:50 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqseyk2hce.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=timofey.vasenin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).