git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Ggordonwwang <gordonwwang@foxmail.com>
Date
Apr 9, 2024, 06:53 UTC
Message-ID
<tencent_A24B502465766F850E47E415283861089809@qq.com>
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

Message 1 of 1 in “git bug Report: Inconsistent behavior caused by [] in.gitignore”
  1. gordonwwangApr 9, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.