From: =?gb18030?B?Z29yZG9ud3dhbmc=?= <gordonwwang@foxmail.com>
To: =?gb18030?B?Z2l0?= <git@vger.kernel.org>
Subject: git bug Report: Inconsistent behavior caused by [] in.gitignore
Date: Tue, 9 Apr 2024 14:53:02 +0800 [thread overview]
Message-ID: <tencent_A24B502465766F850E47E415283861089809@qq.com> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 2008 bytes --]
1. What did you do before the bug happened? (Steps to reproduce your issue)
Create a git repository in the following directory:
.
|-- folder1
| `-- a.txt
|-- folder13
| `-- c.txt
|-- folder2
| `-- b.txt
`-- foo.txt
3 directories, 4 files"
Then edit .gitignore and enter the following:"
# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
# INVALID FILES
# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
folder1[/]
folder2/
folder1[3]
".
2. What did you expect to happen? (Expected behavior)
Execute `git status` and observe that only foo.txt is being tracked.
3. What happened instead? (Actual behavior)
Execute `git status` and observe that folder1/, foo.txt are all tracked.
4. What's different between what you expected and what actually happened?
Execute `git status`, folder1/ should be ignored.
5. Anything else you want to add:
We set up two controlled trials in.gitignore:
1. 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);
2. folder1[/] and folder2/. The folder2/ directory is ignored, and the folder1/ directory is not ignored as expected.
My opinion:
In.gitignore, set ¡°folder1[/]
folder2/¡±, their behavior should be consistent, that is, folder1/ directory and folder2/ directory are not tracked.
When logic is inconsistent, users will find it difficult to understand and become unnecessary bugs.
[System Info]
git version:
git version 2.41.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: 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
compiler info: gnuc: 12.3
libc info: glibc: 2.38
$SHELL (typically, interactive shell): /bin/bash
reply other threads:[~2024-04-09 6:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_A24B502465766F850E47E415283861089809@qq.com \
--to=gordonwwang@foxmail.com \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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).