Skip to content

Commit 462b4e8

Browse files
matheustavaresgitster
authored andcommitted
symlinks: update comment on threaded_check_leading_path()
Since 1d718a5 ("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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0628636 commit 462b4e8

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

symlinks.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -202,36 +202,23 @@ int threaded_has_symlink_leading_path(struct cache_def *cache, const char *name,
202202
return lstat_cache(cache, name, len, FL_SYMLINK|FL_DIR, USE_ONLY_LSTAT) & FL_SYMLINK;
203203
}
204204

205-
/*
206-
* Return non-zero if path 'name' has a leading symlink component
207-
*/
208205
int has_symlink_leading_path(const char *name, int len)
209206
{
210207
return threaded_has_symlink_leading_path(&default_cache, name, len);
211208
}
212209

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-
*/
222210
int check_leading_path(const char *name, int len)
223211
{
224212
return threaded_check_leading_path(&default_cache, name, len);
225213
}
226214

227215
/*
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.
230217
*
231218
* Return -1 if leading path exists and is a directory.
232219
*
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.
235222
*/
236223
static int threaded_check_leading_path(struct cache_def *cache, const char *name, int len)
237224
{
@@ -246,13 +233,6 @@ static int threaded_check_leading_path(struct cache_def *cache, const char *name
246233
return match_len;
247234
}
248235

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-
*/
256236
int has_dirs_only_path(const char *name, int len, int prefix_len)
257237
{
258238
return threaded_has_dirs_only_path(&default_cache, name, len, prefix_len);

0 commit comments

Comments
 (0)