Negation re-includes files under a directory excluded by a directory rule

Đang mở
#7,283 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
c, git
Lĩnh vực
devtools

Hướng nghiên cứu

Tái hiện trường hợp bằng git_ignore_path_is_ignored() hoặc thông qua git_status/git_diff_tree_to_workdir với GIT_DIFF_INCLUDE_UNTRACKED, sử dụng .gitignore và bố cục thư mục đã cho. So sánh kết quả với git check-ignore d/sub/f.txt; done có nghĩa là phép phủ định đối với thư mục con trung gian vẫn khiến tệp bị bỏ qua, khớp với core Git.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Reproduction steps

.gitignore:

d/
!d/sub/*

Layout:

d/
  sub/
    f.txt

Then query whether d/sub/f.txt is ignored, e.g. git_ignore_path_is_ignored(), or
git_status/git_diff_tree_to_workdir with GIT_DIFF_INCLUDE_UNTRACKED.

Expected behavior

d/sub/f.txt is ignored, matching core git: git check-ignore d/sub/f.txt reports it's
excluded by the d/ rule. The !d/sub/* negation has no effect because a parent directory is
excluded — per the gitignore docs: "It is not possible to re-include a file if a parent
directory of that file is excluded."

Actual behavior

libgit2 reports d/sub/f.txt as not ignored (git_ignore_path_is_ignored returns 0, and
it shows up as untracked under GIT_DIFF_INCLUDE_UNTRACKED).

Same result with d/** instead of d/, and with !d/sub/** instead of !d/sub/*.

It works correctly when the negation targets a direct child of the excluded dir
(d/sub/ + !d/sub/f.txt → ignored, agreeing with git); the divergence only appears when the
re-included path sits under an intermediate subdirectory of the excluded directory.

Version of libgit2 (release number or SHA1)

1.9.2

Operating system(s) tested

macOS 15.5 (Apple Silicon)

Ngôn ngữ chính
C
Star
10.6k
Fork
2.7k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của libgit2/libgit2

Tất cả issue của libgit2/libgit2

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.