diff mbox series

[1/2] symlinks: update comment on threaded_check_leading_path()

Message ID ec8d5f86994d91b6dc430ff2e1b79a7cdf8120f9.1616091229.git.matheus.bernardino@usp.br (mailing list archive)
State Accepted
Commit 462b4e8dfd688b8964da77daf17b64da5bdc54ad
Headers show
Series checkout: don't follow symlinks when removing entries | expand

Commit Message

Matheus Tavares March 18, 2021, 6:43 p.m. UTC
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>
---
 symlinks.c | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)
diff mbox series

Patch

diff --git a/symlinks.c b/symlinks.c
index 7dbb6b23d9..fbccd340f0 100644
--- a/symlinks.c
+++ b/symlinks.c
@@ -202,36 +202,23 @@  int threaded_has_symlink_leading_path(struct cache_def *cache, const char *name,
 	return lstat_cache(cache, name, len, FL_SYMLINK|FL_DIR, USE_ONLY_LSTAT) & FL_SYMLINK;
 }
 
-/*
- * Return non-zero if path 'name' has a leading symlink component
- */
 int has_symlink_leading_path(const char *name, int len)
 {
 	return threaded_has_symlink_leading_path(&default_cache, name, len);
 }
 
-/*
- * Return zero if path 'name' has a leading symlink component or
- * if some leading path component does not exists.
- *
- * Return -1 if leading path exists and is a directory.
- *
- * Return path length if leading path exists and is neither a
- * directory nor a symlink.
- */
 int check_leading_path(const char *name, int len)
 {
 	return threaded_check_leading_path(&default_cache, name, len);
 }
 
 /*
- * Return zero if path 'name' has a leading symlink component or
- * if some leading path component does not exists.
+ * Return zero if some leading path component of 'name' does not exist.
  *
  * Return -1 if leading path exists and is a directory.
  *
- * Return path length if leading path exists and is neither a
- * directory nor a symlink.
+ * Return the length of a leading component if it either exists but it's not a
+ * directory, or if we were unable to lstat() it.
  */
 static int threaded_check_leading_path(struct cache_def *cache, const char *name, int len)
 {
@@ -246,13 +233,6 @@  static int threaded_check_leading_path(struct cache_def *cache, const char *name
 		return match_len;
 }
 
-/*
- * Return non-zero if all path components of 'name' exists as a
- * directory.  If prefix_len > 0, we will test with the stat()
- * function instead of the lstat() function for a prefix length of
- * 'prefix_len', thus we then allow for symlinks in the prefix part as
- * long as those points to real existing directories.
- */
 int has_dirs_only_path(const char *name, int len, int prefix_len)
 {
 	return threaded_has_dirs_only_path(&default_cache, name, len, prefix_len);