{"thread":{"id":"61299","subject":"git bug Report: Inconsistent behavior caused by [] in.gitignore","startedAt":"2024-04-09T06:53:05Z","lastAt":"2024-04-09T06:53:05Z","messageCount":1,"participants":["gordonwwang"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"492624","messageId":"tencent_A24B502465766F850E47E415283861089809@qq.com","threadId":"61299","inReplyTo":null,"subject":"git bug Report: Inconsistent behavior caused by [] in.gitignore","fromName":"gordonwwang","fromEmail":"gordonwwang@foxmail.com","sentAt":"2024-04-09T06:53:02Z","receivedAt":"2024-04-09T06:53:05Z","isPatch":false,"sender":{"key":"gordonwwang@foxmail.com","avatar":null},"body":"1. What did you do before the bug happened? (Steps to reproduce your issue)\nCreate a git repository in the following directory:\n.\n|-- folder1\n|   `-- a.txt\n|-- folder13\n|   `-- c.txt\n|-- folder2\n|   `-- b.txt\n`-- foo.txt\n\n3 directories, 4 files\"\n\nThen edit .gitignore and enter the following:\"\n# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -\n# INVALID FILES\n# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -\nfolder1[/]\nfolder2/\nfolder1[3]\n\".\n\n2. What did you expect to happen? (Expected behavior)\nExecute `git status` and observe that only foo.txt is being tracked.\n\n3. What happened instead? (Actual behavior)\nExecute `git status` and observe that folder1/, foo.txt are all tracked.\n\n4. What's different between what you expected and what actually happened?\nExecute `git status`,  folder1/ should be ignored.\n\n5. Anything else you want to add:\nWe set up two controlled trials in.gitignore:\n1. folder1[/] and folder1[3]. The folder13 directory is ignored, indicating that the parentheses [] worked for the number 3, only for the slash /. (The role of the parentheses [] is to select one of the characters, in order to show a sharp contrast, I only wrote one character, please ignore this small detail);\n2. folder1[/] and folder2/. The folder2/ directory is ignored, and the folder1/ directory is not ignored as expected.\n\nMy opinion:\nIn.gitignore, set “folder1[/]\nfolder2/”, their behavior should be consistent, that is, folder1/ directory and folder2/ directory are not tracked.\nWhen logic is inconsistent, users will find it difficult to understand and become unnecessary bugs.\n\n\n[System Info]\ngit version:\ngit version 2.41.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 6.6.6-2401.0.1.1.ocs23.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jan 18 09:42:48 CST 2024 x86_64\ncompiler info: gnuc: 12.3\nlibc info: glibc: 2.38\n$SHELL (typically, interactive shell): /bin/bash"}]}