|
1 |
| -use gix_dir::walk; |
| 1 | +use gix_dir::{walk, EntryRef}; |
2 | 2 | use pretty_assertions::assert_eq;
|
3 | 3 |
|
4 | 4 | use crate::walk_utils::{
|
5 | 5 | collect, collect_filtered, entry, entry_dirstat, entry_nokind, entry_nomatch, entryps, entryps_dirstat, fixture,
|
6 |
| - fixture_in, options, options_emit_all, try_collect, try_collect_filtered_opts, EntryExt, Options, |
| 6 | + fixture_in, options, options_emit_all, try_collect, try_collect_filtered_opts, try_collect_filtered_opts_collect, |
| 7 | + EntryExt, Options, |
7 | 8 | };
|
| 9 | +use gix_dir::entry; |
8 | 10 | use gix_dir::entry::Kind::*;
|
9 | 11 | use gix_dir::entry::PathspecMatch::*;
|
10 | 12 | use gix_dir::entry::Status::*;
|
@@ -1823,7 +1825,7 @@ fn root_may_not_go_through_dot_git() -> crate::Result {
|
1823 | 1825 | #[test]
|
1824 | 1826 | fn root_enters_directory_with_dot_git_in_reconfigured_worktree_tracked() -> crate::Result {
|
1825 | 1827 | let root = fixture("nonstandard-worktree");
|
1826 |
| - let (out, entries) = try_collect_filtered_opts( |
| 1828 | + let (out, entries) = try_collect_filtered_opts_collect( |
1827 | 1829 | &root,
|
1828 | 1830 | |keep, ctx| {
|
1829 | 1831 | walk(
|
@@ -1857,7 +1859,7 @@ fn root_enters_directory_with_dot_git_in_reconfigured_worktree_tracked() -> crat
|
1857 | 1859 | "everything is tracked, so it won't try to detect git repositories anyway"
|
1858 | 1860 | );
|
1859 | 1861 |
|
1860 |
| - let (out, entries) = try_collect_filtered_opts( |
| 1862 | + let (out, entries) = try_collect_filtered_opts_collect( |
1861 | 1863 | &root,
|
1862 | 1864 | |keep, ctx| {
|
1863 | 1865 | walk(
|
@@ -1891,7 +1893,7 @@ fn root_enters_directory_with_dot_git_in_reconfigured_worktree_tracked() -> crat
|
1891 | 1893 | #[test]
|
1892 | 1894 | fn root_enters_directory_with_dot_git_in_reconfigured_worktree_untracked() -> crate::Result {
|
1893 | 1895 | let root = fixture("nonstandard-worktree-untracked");
|
1894 |
| - let (_out, entries) = try_collect_filtered_opts( |
| 1896 | + let (_out, entries) = try_collect_filtered_opts_collect( |
1895 | 1897 | &root,
|
1896 | 1898 | |keep, ctx| {
|
1897 | 1899 | walk(
|
@@ -2091,6 +2093,69 @@ fn root_can_be_pruned_early_with_pathspec() -> crate::Result {
|
2091 | 2093 | Ok(())
|
2092 | 2094 | }
|
2093 | 2095 |
|
| 2096 | +#[test] |
| 2097 | +fn cancel_with_collection_does_not_fail() -> crate::Result { |
| 2098 | + struct CancelDelegate { |
| 2099 | + emits_left_until_cancel: usize, |
| 2100 | + } |
| 2101 | + |
| 2102 | + impl gix_dir::walk::Delegate for CancelDelegate { |
| 2103 | + fn emit(&mut self, _entry: EntryRef<'_>, _collapsed_directory_status: Option<entry::Status>) -> walk::Action { |
| 2104 | + if self.emits_left_until_cancel == 0 { |
| 2105 | + walk::Action::Cancel |
| 2106 | + } else { |
| 2107 | + self.emits_left_until_cancel -= 1; |
| 2108 | + dbg!(self.emits_left_until_cancel); |
| 2109 | + walk::Action::Continue |
| 2110 | + } |
| 2111 | + } |
| 2112 | + } |
| 2113 | + |
| 2114 | + for (idx, fixture_name) in [ |
| 2115 | + "nonstandard-worktree", |
| 2116 | + "nonstandard-worktree-untracked", |
| 2117 | + "dir-with-file", |
| 2118 | + "expendable-and-precious", |
| 2119 | + "subdir-untracked-and-ignored", |
| 2120 | + "empty-and-untracked-dir", |
| 2121 | + "complex-empty", |
| 2122 | + "type-mismatch-icase-clash-file-is-dir", |
| 2123 | + ] |
| 2124 | + .into_iter() |
| 2125 | + .enumerate() |
| 2126 | + { |
| 2127 | + let root = fixture(fixture_name); |
| 2128 | + let mut dlg = CancelDelegate { |
| 2129 | + emits_left_until_cancel: idx, |
| 2130 | + }; |
| 2131 | + let _out = try_collect_filtered_opts( |
| 2132 | + &root, |
| 2133 | + |keep, ctx| { |
| 2134 | + walk( |
| 2135 | + &root, |
| 2136 | + &root, |
| 2137 | + ctx, |
| 2138 | + walk::Options { |
| 2139 | + emit_untracked: CollapseDirectory, |
| 2140 | + emit_ignored: Some(CollapseDirectory), |
| 2141 | + emit_empty_directories: true, |
| 2142 | + emit_tracked: true, |
| 2143 | + for_deletion: Some(Default::default()), |
| 2144 | + emit_pruned: true, |
| 2145 | + ..options() |
| 2146 | + }, |
| 2147 | + keep, |
| 2148 | + ) |
| 2149 | + }, |
| 2150 | + None::<&str>, |
| 2151 | + &mut dlg, |
| 2152 | + Options::default(), |
| 2153 | + )?; |
| 2154 | + // Note that this also doesn't trigger an error - the caller has to deal with that. |
| 2155 | + } |
| 2156 | + Ok(()) |
| 2157 | +} |
| 2158 | + |
2094 | 2159 | #[test]
|
2095 | 2160 | fn file_root_is_shown_if_pathspec_matches_exactly() -> crate::Result {
|
2096 | 2161 | let root = fixture("dir-with-file");
|
@@ -2751,7 +2816,7 @@ fn partial_checkout_cone_and_non_one() -> crate::Result {
|
2751 | 2816 | #[test]
|
2752 | 2817 | fn type_mismatch() {
|
2753 | 2818 | let root = fixture("type-mismatch");
|
2754 |
| - let (out, entries) = try_collect_filtered_opts( |
| 2819 | + let (out, entries) = try_collect_filtered_opts_collect( |
2755 | 2820 | &root,
|
2756 | 2821 | |keep, ctx| {
|
2757 | 2822 | walk(
|
@@ -2794,7 +2859,7 @@ fn type_mismatch() {
|
2794 | 2859 | The typechange is visible only when there is an entry in the index, of course"
|
2795 | 2860 | );
|
2796 | 2861 |
|
2797 |
| - let (out, entries) = try_collect_filtered_opts( |
| 2862 | + let (out, entries) = try_collect_filtered_opts_collect( |
2798 | 2863 | &root,
|
2799 | 2864 | |keep, ctx| {
|
2800 | 2865 | walk(
|
@@ -2839,7 +2904,7 @@ fn type_mismatch() {
|
2839 | 2904 | #[test]
|
2840 | 2905 | fn type_mismatch_ignore_case() {
|
2841 | 2906 | let root = fixture("type-mismatch-icase");
|
2842 |
| - let (out, entries) = try_collect_filtered_opts( |
| 2907 | + let (out, entries) = try_collect_filtered_opts_collect( |
2843 | 2908 | &root,
|
2844 | 2909 | |keep, ctx| {
|
2845 | 2910 | walk(
|
@@ -2879,7 +2944,7 @@ fn type_mismatch_ignore_case() {
|
2879 | 2944 | "this is the same as in the non-icase version, which means that icase lookup works"
|
2880 | 2945 | );
|
2881 | 2946 |
|
2882 |
| - let (out, entries) = try_collect_filtered_opts( |
| 2947 | + let (out, entries) = try_collect_filtered_opts_collect( |
2883 | 2948 | &root,
|
2884 | 2949 | |keep, ctx| {
|
2885 | 2950 | walk(
|
@@ -2923,7 +2988,7 @@ fn type_mismatch_ignore_case() {
|
2923 | 2988 | #[test]
|
2924 | 2989 | fn type_mismatch_ignore_case_clash_dir_is_file() {
|
2925 | 2990 | let root = fixture("type-mismatch-icase-clash-dir-is-file");
|
2926 |
| - let (out, entries) = try_collect_filtered_opts( |
| 2991 | + let (out, entries) = try_collect_filtered_opts_collect( |
2927 | 2992 | &root,
|
2928 | 2993 | |keep, ctx| {
|
2929 | 2994 | walk(
|
@@ -2964,7 +3029,7 @@ fn type_mismatch_ignore_case_clash_dir_is_file() {
|
2964 | 3029 | #[test]
|
2965 | 3030 | fn type_mismatch_ignore_case_clash_file_is_dir() {
|
2966 | 3031 | let root = fixture("type-mismatch-icase-clash-file-is-dir");
|
2967 |
| - let (out, entries) = try_collect_filtered_opts( |
| 3032 | + let (out, entries) = try_collect_filtered_opts_collect( |
2968 | 3033 | &root,
|
2969 | 3034 | |keep, ctx| {
|
2970 | 3035 | walk(
|
|
0 commit comments