symlinks: update comment on threaded_check_leading_path()

Since 1d718a5108 ("do not overwrite untracked symlinks", 2011-02-20), the comment on top of threaded_check_leading_path() is outdated and no longer reflects the behavior of this function. Let's updated it to avoid confusions. While we are here, also remove some duplicated comments to avoid similar maintenance problems. Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matheus Tavares committed Mar 18, 2021 at 15:43 UTC 462b4e8dfd688b8964da77daf17b64da5bdc54ad
1 file changed +3 -23
symlinks.c
+3 -23
@@ -202,36 +202,23 @@ int threaded_has_symlink_leading_path(struct cache_def *cache, const char *name,
202 return lstat_cache(cache, name, len, FL_SYMLINK|FL_DIR, USE_ONLY_LSTAT) & FL_SYMLINK;
203 }
204
205 -/*
206 - * Return non-zero if path 'name' has a leading symlink component
207 - */
205 int has_symlink_leading_path(const char *name, int len)
206 {
207 return threaded_has_symlink_leading_path(&default_cache, name, len);
208 }
209
213 -/*
214 - * Return zero if path 'name' has a leading symlink component or
215 - * if some leading path component does not exists.
216 - *
217 - * Return -1 if leading path exists and is a directory.
218 - *
219 - * Return path length if leading path exists and is neither a
220 - * directory nor a symlink.
221 - */
210 int check_leading_path(const char *name, int len)
211 {
212 return threaded_check_leading_path(&default_cache, name, len);
213 }
214
215 /*
228 - * Return zero if path 'name' has a leading symlink component or
229 - * if some leading path component does not exists.
216 + * Return zero if some leading path component of 'name' does not exist.
217 *
218 * Return -1 if leading path exists and is a directory.
219 *
233 - * Return path length if leading path exists and is neither a
234 - * directory nor a symlink.
220 + * Return the length of a leading component if it either exists but it's not a
221 + * directory, or if we were unable to lstat() it.
222 */
223 static int threaded_check_leading_path(struct cache_def *cache, const char *name, int len)
224 {
@@ -246,13 +233,6 @@ static int threaded_check_leading_path(struct cache_def *cache, const char *name
233 return match_len;
234 }
235
249 -/*
250 - * Return non-zero if all path components of 'name' exists as a
251 - * directory. If prefix_len > 0, we will test with the stat()
252 - * function instead of the lstat() function for a prefix length of
253 - * 'prefix_len', thus we then allow for symlinks in the prefix part as
254 - * long as those points to real existing directories.
255 - */
236 int has_dirs_only_path(const char *name, int len, int prefix_len)
237 {
238 return threaded_has_dirs_only_path(&default_cache, name, len, prefix_len);