Unified · Split
| @@ -92,6 +92,7 @@ impl Attributes { · 91 unmodified lines | ||
| 92 | 92 | let attr_file_in_index = id_mappings.binary_search_by(|t| t.0.as_bstr().cmp(attr_path_relative.as_ref())); |
| 93 | 93 | // Git does not follow symbolic links as per documentation. |
| 94 | 94 | let no_follow_symlinks = false; |
| 95 | + let read_macros_as_dir_is_root = root == dir; | |
| 95 | 96 | |
| 96 | 97 | let mut added = false; |
| 97 | 98 | match self.source { |
| @@ -100,8 +101,13 @@ impl Attributes { · 2 unmodified lines | ||
| 100 | 101 | let blob = find(&id_mappings[idx].1, buf) |
| 101 | 102 | .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; |
| 102 | 103 | let attr_path = gix_path::from_bstring(attr_path_relative.into_owned()); |
| 103 | − self.stack | |
| 104 | − .add_patterns_buffer(blob.data, attr_path, Some(Path::new("")), &mut self.collection); | |
| 104 | + self.stack.add_patterns_buffer( | |
| 105 | + blob.data, | |
| 106 | + attr_path, | |
| 107 | + Some(Path::new("")), | |
| 108 | + &mut self.collection, | |
| 109 | + read_macros_as_dir_is_root, | |
| 110 | + ); | |
| 105 | 111 | added = true; |
| 106 | 112 | stats.patterns_buffers += 1; |
| 107 | 113 | } |
| @@ -112,6 +118,7 @@ impl Attributes { · 4 unmodified lines | ||
| 112 | 118 | Some(root), |
| 113 | 119 | buf, |
| 114 | 120 | &mut self.collection, |
| 121 | + read_macros_as_dir_is_root, | |
| 115 | 122 | )?; |
| 116 | 123 | stats.pattern_files += usize::from(added); |
| 117 | 124 | stats.tried_pattern_files += 1; |
| @@ -124,6 +131,7 @@ impl Attributes { · 6 unmodified lines | ||
| 124 | 131 | Some(root), |
| 125 | 132 | buf, |
| 126 | 133 | &mut self.collection, |
| 134 | + read_macros_as_dir_is_root, | |
| 127 | 135 | )?; |
| 128 | 136 | stats.pattern_files += usize::from(added); |
| 129 | 137 | stats.tried_pattern_files += 1; |
| @@ -131,8 +139,13 @@ impl Attributes { · 1 unmodified line | ||
| 131 | 139 | let blob = find(&id_mappings[idx].1, buf) |
| 132 | 140 | .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; |
| 133 | 141 | let attr_path = gix_path::from_bstring(attr_path_relative.into_owned()); |
| 134 | − self.stack | |
| 135 | − .add_patterns_buffer(blob.data, attr_path, Some(Path::new("")), &mut self.collection); | |
| 142 | + self.stack.add_patterns_buffer( | |
| 143 | + blob.data, | |
| 144 | + attr_path, | |
| 145 | + Some(Path::new("")), | |
| 146 | + &mut self.collection, | |
| 147 | + read_macros_as_dir_is_root, | |
| 148 | + ); | |
| 136 | 149 | added = true; |
| 137 | 150 | stats.patterns_buffers += 1; |
| 138 | 151 | } |
| @@ -142,15 +155,20 @@ impl Attributes { · 3 unmodified lines | ||
| 142 | 155 | // Need one stack level per component so push and pop matches, but only if this isn't the root level which is never popped. |
| 143 | 156 | if !added && self.info_attributes.is_none() { |
| 144 | 157 | self.stack |
| 145 | − .add_patterns_buffer(&[], Path::new("<empty dummy>"), None, &mut self.collection) | |
| 158 | + .add_patterns_buffer(&[], Path::new("<empty dummy>"), None, &mut self.collection, true) | |
| 146 | 159 | } |
| 147 | 160 | |
| 148 | 161 | // When reading the root, always the first call, we can try to also read the `.git/info/attributes` file which is |
| 149 | 162 | // by nature never popped, and follows the root, as global. |
| 150 | 163 | if let Some(info_attr) = self.info_attributes.take() { |
| 151 | − let added = self | |
| 152 | − .stack | |
| 153 | − .add_patterns_file(info_attr, true, None, buf, &mut self.collection)?; | |
| 164 | + let added = self.stack.add_patterns_file( | |
| 165 | + info_attr, | |
| 166 | + true, | |
| 167 | + None, | |
| 168 | + buf, | |
| 169 | + &mut self.collection, | |
| 170 | + true, /* read macros */ | |
| 171 | + )?; | |
| 154 | 172 | stats.pattern_files += usize::from(added); |
| 155 | 173 | stats.tried_pattern_files += 1; |
| 156 | 174 | } |