Open shoffmeister opened 3 years ago
Taking a quick peek at the implementation, it would seem as if getAheadFilesQuery
and getBehindFilesQuery
both use getDiffStatus
underneath - which then uses git diff
- and git diff
will disregard added files (and, apparently, cannot be convinced to mix in files added in the working directory).
Perhaps it would make (more) sense to use the output of git status
for preparing the view output against the working directory? After all, gitlens uses the git output only for populating the view, so:
> git status --short
MM README.md
A missing-in-comparison.txt
D tsconfig.json
might be fine?
EDIT: git status
does not allow specifying a ref (it is relative to the index) - so that's a a no-go. Perhaps git ls-files --others -t
to identify files in the working tree which are not known to the index, and then simply mix that into the (existing) comparison? After all, it is not important to get content comparison right, only to identify the set of files?
The "Search & Compare" view has the option to perform a comparison of the "Working Tree" against, e.g., main.
Alas, a comparison of "Working Tree" misses out on untracked files ("U") present in the current working tree. Staging any untracked files (adding them to the index) will make them show up in the comparison.
Now, this is not only a simple wording challenge between "Working Tree" and "Index", because already tracked files ("M" or "D") are considered for comparison from the working tree (and not the index).
Steps to Reproduce:
Problem - untracked + unstaged files not listed:
touch missing-in-comparison.txt
Refresh compare references view created above //exp: missing-in-comparison.txt present as a difference //act: no differences shown
stage the untracked file from the working tree into the index:
git add missing-in-comparison.txt
Refresh compare references view created above //exp: missing-in-comparison.txt present as a difference //act: expectations met, all good
Bonus - changes are indeed shown from the working tree, not from the index (correct behaviour)
echo '1' > README.md
Refresh compare references view created above //exp: '1' shown as difference //act: expectations met, all good
git add README.md
echo '2' > README.md
Refresh compare references view created above //exp: '2' shown as difference //act: expectations met, all good
Bonus - delete is also shown correctly
rm tsconfig.json