New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BF: gitrepo: Work around change in 'ls-files -o' output #3904
Conversation
Looks like that resolved the two tests that were failing due to changed |
Thanks a lot @kyleam for the analysis and the fix!! |
As described in the previous commit, the traversal behavior of 'ls-files -o' in the latest release of Git, v2.24.0, has changed. The workaround in that commit fixed two tests that failed with v2.24.0, but there is a remaining failure, test_path_diff [0]. Local testing confirmed that it is due to the same change in Git, 89a1f4aaf7 (dir: if our pathspec might match files under a dir, recurse into it, 2019-09-17). The failures addressed in the last commit were about 'ls-files -o' without --directory traversing into untracked nested repositories when multiple pathspecs are given. In contrast the test_path_diff failure happens due to traversing into a plain untracked directory when --directory is specified along with multiple pathspecs. For example, before 89a1f4aaf7 the following will not traverse into an untracked directory: git-89a1f4aaf7^ $ git ls-files -o --directory . a a untracked-dir/ As of 89a1f4aaf7 the same command includes untracked content from the untracked directory: git-89a1f4aaf7 $ git ls-files -o --directory . a a untracked-dir/ untracked-dir/b Note that if the "a" pathspec were dropped, the call would _not_ traverse into the untracked directory (i.e., "untracked-dir/b" would not be included). For now let's just skip the assertion on Git v2.24 because (1) unlike the GitRepo.save_() case from the previous commit, it's not clear that this discrepancy in the 'datalad diff' output is critical in any way, and (2) it looks like the change in behavior may be addressed upstream. [0]: datalad#3904 (comment)
Codecov Report
@@ Coverage Diff @@
## master #3904 +/- ##
===========================================
+ Coverage 46.74% 80.66% +33.91%
===========================================
Files 269 272 +3
Lines 36045 36065 +20
===========================================
+ Hits 16850 29091 +12241
+ Misses 19195 6974 -12221
Continue to review full report at Codecov.
|
save_() calls 'ls-files -o' on a list of untracked directories to determine which directories correspond to untracked submodules. If the directories remain unexpanded in the 'ls-files -o' output, they are taken as submodules. This method of identifying untracked submodules breaks [0,1] with the latest release of Git (v2.24.0) due to an unintentional change in the 'ls-files -o' output [2]: when given _multiple_ pathspecs, 'ls-files -o' recurses into untracked submodules and lists the files from the submodule (even the tracked ones). save_() filters the output to directories, so most of the additional entries are removed, but when the submodule itself has submodules (untracked or tracked) these and those from any deeper levels are included in the output. save_() passes these deeper repositories to add_submodule(), which as expected leads to 'git submodule add' failing. This behavior will hopefully be addressed in Git itself [2], but we should still provide a workaround for the current version of Git. Add a helper that filters these deeper repositories from the list of submodules that save_() feeds to add_submodule(). This approach takes advantage of the fact that, even when 'ls-files -o' misbehaves and traverses into the submodule, it still reports an unexpanded entry. If the unexpanded entry weren't present, we wouldn't be able to distinguish a submodule from a regular directory. Note that the helper is conditionally defined at the module level; for earlier versions of Git that don't need this kludge, this reduces the cost per save_() call to a single call to an identity function. [0]: datalad#3890 (comment) [1]: datalad#3902 (comment) [2]: https://lore.kernel.org/git/87fti15agv.fsf@kyleam.com/T/#u
As described in the previous commit, the traversal behavior of 'ls-files -o' in the latest release of Git, v2.24.0, has changed. The workaround in that commit fixed two tests that failed with v2.24.0, but there is a remaining failure, test_path_diff [0]. Local testing confirmed that it is due to the same change in Git, 89a1f4aaf7 (dir: if our pathspec might match files under a dir, recurse into it, 2019-09-17). The failures addressed in the last commit were about 'ls-files -o' without --directory traversing into untracked nested repositories when multiple pathspecs are given. In contrast the test_path_diff failure happens due to traversing into a plain untracked directory when --directory is specified along with multiple pathspecs. For example, before 89a1f4aaf7 the following will not traverse into an untracked directory: git-89a1f4aaf7^ $ git ls-files -o --directory . a a untracked-dir/ As of 89a1f4aaf7 the same command includes untracked content from the untracked directory: git-89a1f4aaf7 $ git ls-files -o --directory . a a untracked-dir/ untracked-dir/b Note that if the "a" pathspec were dropped, the call would _not_ traverse into the untracked directory (i.e., "untracked-dir/b" would not be included). For now let's just skip the assertion on Git v2.24 because (1) unlike the GitRepo.save_() case from the previous commit, it's not clear that this discrepancy in the 'datalad diff' output is critical in any way, and (2) it looks like the change in behavior may be addressed upstream. [0]: datalad#3904 (comment)
The failure was indeed related to the same range-diff
|
The travis build with the latest git and the github action that uses the latest git both passed. I'll drop the tip commit. |
Great! Appveyor stalls in the 2nd run, but that is nothing new. Will merge. |
0: #3890 (comment)
1: #3902 (comment)
2: https://lore.kernel.org/git/87fti15agv.fsf@kyleam.com/T/#u
Marking as "do not merge" because the tip commit should be dropped before merging.