libgit2 / libgit2/libgit2

git_status_list with pathspec and disable_pathspec_match not returning untracked items in subdirectories

未关闭
#4,315 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C
星标
10.6k
派生
2.7k
PR 合并指标
30 天内没有已合并 PR

描述

I think there might be something slightly incorrect about libgit2's handling of status lists for untracked files within subdirectories when scoping specifically to a file by pathspec.

Reproduction steps

Consider I have a repository with the following structure, where the Committed files are checked in to the repository, and Uncommitted files are untracked in the working directory:

root/
    Committed.txt
    Uncommitted.txt
    subdirectory/
        Committed2.txt
        Uncommitted2.txt

I'm calling git_status_list_new with the following options and flags:

.pathspec = "subdirectory/Uncommitted2.txt"
GIT_STATUS_OPT_INCLUDE_UNTRACKED
GIT_STATUS_OPT_INCLUDE_UNMODIFIED
GIT_STATUS_OPT_INCLUDE_IGNORED
GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH

In this case, no entries are returned for the file. If I switch the path spec to just "Uncommitted.txt", it works and returns an entry with the GIT_STATUS_WT_NEW status. Similarly, if I create a status list without any pathspec returning all files, an entry for the file is included.

I believe the subdirectory itself is considered committed, since Committed2.txt is committed. If I add the GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS flag, it also works as expected for the subdirectory, but this has a bit of overhead for directories that are fully untracked.

I suspect this is not working as intended (since it works for the root case, just not in subdirectories). If this is not the case, or I'm somehow using the pathspec matching incorrectly, let me know!

I will attach an example repository (although it's not too complex).

Expected behavior

The status list should return one entry with GIT_STATUS_WT_NEW status for the second uncommitted file.

Actual behavior

No entries are returned in the status list.

Version of libgit2 (release number or SHA1)

Checked with the latest version, e056862.

Operating system(s) tested

macOS 10.12.5

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 git_status_list_new 开始,使用 GIT_STATUS_OPT_INCLUDE_UNTRACKED、GIT_STATUS_OPT_INCLUDE_UNMODIFIED、GIT_STATUS_OPT_INCLUDE_IGNORED 和 GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH 重现子目录 pathspec 情况。将其与根目录文件和无 pathspec 的情况进行比较。当状态列表返回带有 GIT_STATUS_WT_NEW 的子目录文件,且不需要 GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS 时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
c, git
领域
devtools
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。