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