* git bug Report: Inconsistent behavior caused by [] in.gitignore
@ 2024-04-09 6:53 =?gb18030?B?Z29yZG9ud3dhbmc=?=
0 siblings, 0 replies; only message in thread
From: =?gb18030?B?Z29yZG9ud3dhbmc=?= @ 2024-04-09 6:53 UTC (permalink / raw)
To: =?gb18030?B?Z2l0?=
[-- 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-09 6:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-09 6:53 git bug Report: Inconsistent behavior caused by [] in.gitignore =?gb18030?B?Z29yZG9ud3dhbmc=?=
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 NNTP newsgroup(s).