git_status_list with pathspec and disable_pathspec_match not returning untracked items in subdirectories
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 10.6k
- Forks
- 2.7k
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with git_status_list_new and reproduce the subdirectory pathspec case using GIT_STATUS_OPT_INCLUDE_UNTRACKED, GIT_STATUS_OPT_INCLUDE_UNMODIFIED, GIT_STATUS_OPT_INCLUDE_IGNORED, and GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH. Compare it with the root-file and no-pathspec cases. Done means the status list returns the subdirectory file with GIT_STATUS_WT_NEW without requiring GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, git
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100