{"thread":{"id":"61471","subject":"[PATCH] gitignore.txt: fix slash-rules example","startedAt":"2024-05-14T16:53:06Z","lastAt":"2024-05-14T21:50:44Z","messageCount":2,"participants":["Timofey Vasenin via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"494725","messageId":"pull.1720.git.git.1715705582609.gitgitgadget@gmail.com","threadId":"61471","inReplyTo":null,"subject":"[PATCH] gitignore.txt: fix slash-rules example","fromName":"Timofey Vasenin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-05-14T16:53:02Z","receivedAt":"2024-05-14T16:53:06Z","isPatch":true,"sender":{"key":"name:Timofey Vasenin","avatar":null},"body":"From: Timofey Vasenin <timofey.vasenin@gmail.com>\n\nFix an apparent typo, introduced in:\n1a58bad014 (gitignore.txt: make slash-rules more readable, 2019-06-04)\n\nReported-by: Andrey Strizhkin <astrizhkin@biarum.com>\nSigned-off-by: Timofey Vasenin <timofey.vasenin@gmail.com>\n---\n    gitignore.txt: fix slash-rules example\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1720%2Ftvasenin%2Ftvasenin%2Fgitignore-slash-rules-example-fix-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1720/tvasenin/tvasenin/gitignore-slash-rules-example-fix-v1\nPull-Request: https://github.com/git/git/pull/1720\n\n Documentation/gitignore.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt\nindex 5e0964ef419..7142fa10acc 100644\n--- a/Documentation/gitignore.txt\n+++ b/Documentation/gitignore.txt\n@@ -100,7 +100,7 @@ PATTERN FORMAT\n    will only match directories, otherwise the pattern can match both\n    files and directories.\n \n- - For example, a pattern `doc/frotz/` matches `doc/frotz` directory,\n+ - For example, a pattern `/doc/frotz/` matches `doc/frotz` directory,\n    but not `a/doc/frotz` directory; however `frotz/` matches `frotz`\n    and `a/frotz` that is a directory (all paths are relative from\n    the `.gitignore` file).\n\nbase-commit: 3e4a232f6e3bd3b7dd920bb07b21cf1c8b4e1a7f\n-- \ngitgitgadget\n"},{"id":"494751","messageId":"xmqqseyk2hce.fsf@gitster.g","threadId":"61471","inReplyTo":"pull.1720.git.git.1715705582609.gitgitgadget@gmail.com","subject":"Re: [PATCH] gitignore.txt: fix slash-rules example","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-05-14T21:50:41Z","receivedAt":"2024-05-14T21:50:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Timofey Vasenin via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Timofey Vasenin <timofey.vasenin@gmail.com>\n>\n> Fix an apparent typo, introduced in:\n> 1a58bad014 (gitignore.txt: make slash-rules more readable, 2019-06-04)\n> ...\n> diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt\n> index 5e0964ef419..7142fa10acc 100644\n> --- a/Documentation/gitignore.txt\n> +++ b/Documentation/gitignore.txt\n> @@ -100,7 +100,7 @@ PATTERN FORMAT\n>     will only match directories, otherwise the pattern can match both\n>     files and directories.\n>  \n> - - For example, a pattern `doc/frotz/` matches `doc/frotz` directory,\n> + - For example, a pattern `/doc/frotz/` matches `doc/frotz` directory,\n>     but not `a/doc/frotz` directory; however `frotz/` matches `frotz`\n>     and `a/frotz` that is a directory (all paths are relative from\n>     the `.gitignore` file).\n\nAre you sure this is a typo?\n\nThe text added by the same commit (taken from \"git show 1a58bad014\")\nhas this passage:\n\n+ - The pattern `doc/frotz` and `/doc/frotz` have the same effect\n+   in any `.gitignore` file. In other words, a leading slash\n+   is not relevant  if there is already a middle slash in\n+   the pattern.\n\nSo, if your updated /doc/frotz/ works as described (i.e. match\ndoc/frotz but not a/doc/frotz), then the original doc/frotz/ should\nbehave exactly the same way, no?  If you have a good reason to believe\nthat doc/frotz/ described there should be /doc/frotz/ instead, then\nyou need to also update that \"have the same effect\" paragraph.\n\nThere should already be an existing test that checks it somewhere\nunder t/; finding one is left as an exercise (or punishment) to\nreaders ;-).\n\nIt is easy to construct a test case from scratch.\n\n    $ mkdir -p doc/frotz/ a/doc/frotz/\n    $ >doc/frotz/foo\n    $ >a/doc/frotz/bar\n    $ echo doc/frotz >.gitignore\n    $ git check-ignore -v doc/frotz/foo a/doc/frotz/bar\n    .gitignore:1:doc/frotz\tdoc/frotz/foo\n\nIt seems that doc/frotz seems to work exactly as described, matching\nwith doc/frotz/foo but not with a/doc/frotz/bar, without a leading\nslash, thanks to a slash in the middle.\n\nSo...\n\n"}]}