{"thread":{"id":"61841","subject":"Re: Possible bug in .gitignore","startedAt":"2024-07-25T04:01:56Z","lastAt":"2024-07-26T05:26:22Z","messageCount":2,"participants":["KwonHyun Kim","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"499307","messageId":"CADLV-7JN-x8+Y+sVO=O-f4Ur7jw8Bs+z0BzQy5y9GbPTJ9eE_g@mail.gmail.com","threadId":"61841","inReplyTo":"CADLV-7+fX7jrC8e_nPBHZfg8yXKpjLfPL3MgxS8peUrr8pqQoA@mail.gmail.com","subject":"Re: Possible bug in .gitignore","fromName":"KwonHyun Kim","fromEmail":"kwonhyun.kim@gmail.com","sentAt":"2024-07-25T04:01:45Z","receivedAt":"2024-07-25T04:01:56Z","isPatch":false,"sender":{"key":"kwonhyun.kim@gmail.com","avatar":null},"body":"Hello,\n\nI am experimenting with git and I found there is something not working\nas explain in the document\n\nWhen I place `text_[가나].txt` in `.gitignore` it does not ignore\ntext_가.txt nor text_나.txt\n\nI experimented with `text_[ab].txt` and it works fine.\n\nSo I thought it might work bytewise so I put\n`text_[\\200-\\352][\\200-\\352][\\200-\\352].txt` with no effect. (가 is\n\"\\352\\260\\200\" when core.quotepath is set to true)\n\nSo I think it must be a bug that is that pattern [abc] or [a-z] does\nnot incorporate non-ascii characters. but I am not sure.\n\nThank you for  reading and hope to hear from you guys soon\n\nKwH Kim.\n\n# ====\nHere is my spec\n\nPRETTY_NAME=\"Ubuntu 24.04 LTS\"\nNAME=\"Ubuntu\"\nVERSION_ID=\"24.04\"\nVERSION=\"24.04 LTS (Noble Numbat)\"\nVERSION_CODENAME=noble\nID=ubuntu\nID_LIKE=debian\nHOME_URL=\"https://www.ubuntu.com/\"\nSUPPORT_URL=\"https://help.ubuntu.com/\"\nBUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"\nPRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\nUBUNTU_CODENAME=noble\nLOGO=ubuntu-logo\n\ngit version\ngit version 2.43.0\n\nLANG=ko_KR.UTF-8\nLANGUAGE=ko:en\nLC_CTYPE=\"ko_KR.UTF-8\"\nLC_NUMERIC=ko_KR.UTF-8\nLC_TIME=ko_KR.UTF-8\nLC_COLLATE=\"ko_KR.UTF-8\"\nLC_MONETARY=ko_KR.UTF-8\nLC_MESSAGES=\"ko_KR.UTF-8\"\nLC_PAPER=ko_KR.UTF-8\nLC_NAME=ko_KR.UTF-8\nLC_ADDRESS=ko_KR.UTF-8\nLC_TELEPHONE=ko_KR.UTF-8\nLC_MEASUREMENT=ko_KR.UTF-8\nLC_IDENTIFICATION=ko_KR.UTF-8\nLC_ALL=\n"},{"id":"499390","messageId":"20240726052621.GA647916@coredump.intra.peff.net","threadId":"61841","inReplyTo":"CADLV-7JN-x8+Y+sVO=O-f4Ur7jw8Bs+z0BzQy5y9GbPTJ9eE_g@mail.gmail.com","subject":"Re: Possible bug in .gitignore","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-07-26T05:26:21Z","receivedAt":"2024-07-26T05:26:22Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jul 25, 2024 at 01:01:45PM +0900, KwonHyun Kim wrote:\n\n> I am experimenting with git and I found there is something not working\n> as explain in the document\n> \n> When I place `text_[가나].txt` in `.gitignore` it does not ignore\n> text_가.txt nor text_나.txt\n> \n> I experimented with `text_[ab].txt` and it works fine.\n> \n> So I thought it might work bytewise so I put\n> `text_[\\200-\\352][\\200-\\352][\\200-\\352].txt` with no effect. (가 is\n> \"\\352\\260\\200\" when core.quotepath is set to true)\n> \n> So I think it must be a bug that is that pattern [abc] or [a-z] does\n> not incorporate non-ascii characters. but I am not sure.\n\nThe globbing in git is generally done by wildmatch.c, which was imported\nfrom rsync. Looking in that file, it looks like it does not support\nmulti-byte characters at all inside brackets.\n\nSo I don't see a way to make it work except to place the _literal_ bytes\nmaking up the utf8 sequence, each inside its own single-byte match.\nLike:\n\n  printf 'text_[\\352\\353][\\260\\202][\\200\\230].txt\\n' >.gitignore\n\nBut then your .gitignore file is itself invalid utf8 (not to mention\nthat this is obviously something a user shouldn't have to do).\n\nSo I guess the fix would be to teach wildmatch.c to recognize and match\nmulti-byte sequences inside []. That probably requires that we assume\nthe pattern and the path are utf8, which will usually be true, but not\nalways. So we might need some kind of config switch there.\n\nThere are also probably a deep rabbit hole of corner cases there (e.g.,\nNFD vs NFC, matching é versus \"e\" + combining accent). But I suspect\nthat even recognizing multi-byte sequences as a single char to match\nwould be big improvement.\n\n-Peff\n"}]}