git bug Report: Inconsistent behavior caused by [] in.gitignore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux