Skip to content

Commit f2a782b

Browse files
j6tgitster
authored andcommitted
Remove unused normalize_absolute_path()
This function is now superseded by normalize_path_copy(). Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f42302b commit f2a782b

File tree

2 files changed

+6
-46
lines changed

2 files changed

+6
-46
lines changed

cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,6 @@ static inline int is_absolute_path(const char *path)
547547
const char *make_absolute_path(const char *path);
548548
const char *make_nonrelative_path(const char *path);
549549
const char *make_relative_path(const char *abs, const char *base);
550-
int normalize_absolute_path(char *buf, const char *path);
551550
int normalize_path_copy(char *dst, const char *src);
552551
int longest_ancestor_length(const char *path, const char *prefix_list);
553552

path.c

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -363,58 +363,19 @@ const char *make_relative_path(const char *abs, const char *base)
363363
}
364364

365365
/*
366-
* path = absolute path
367-
* buf = buffer of at least max(2, strlen(path)+1) bytes
368-
* It is okay if buf == path, but they should not overlap otherwise.
366+
* It is okay if dst == src, but they should not overlap otherwise.
369367
*
370-
* Performs the following normalizations on path, storing the result in buf:
371-
* - Removes trailing slashes.
372-
* - Removes empty components.
368+
* Performs the following normalizations on src, storing the result in dst:
369+
* - Ensures that components are separated by '/' (Windows only)
370+
* - Squashes sequences of '/'.
373371
* - Removes "." components.
374372
* - Removes ".." components, and the components the precede them.
375-
* "" and paths that contain only slashes are normalized to "/".
376-
* Returns the length of the output.
373+
* Returns failure (non-zero) if a ".." component appears as first path
374+
* component anytime during the normalization. Otherwise, returns success (0).
377375
*
378376
* Note that this function is purely textual. It does not follow symlinks,
379377
* verify the existence of the path, or make any system calls.
380378
*/
381-
int normalize_absolute_path(char *buf, const char *path)
382-
{
383-
const char *comp_start = path, *comp_end = path;
384-
char *dst = buf;
385-
int comp_len;
386-
assert(buf);
387-
assert(path);
388-
389-
while (*comp_start) {
390-
assert(*comp_start == '/');
391-
while (*++comp_end && *comp_end != '/')
392-
; /* nothing */
393-
comp_len = comp_end - comp_start;
394-
395-
if (!strncmp("/", comp_start, comp_len) ||
396-
!strncmp("/.", comp_start, comp_len))
397-
goto next;
398-
399-
if (!strncmp("/..", comp_start, comp_len)) {
400-
while (dst > buf && *--dst != '/')
401-
; /* nothing */
402-
goto next;
403-
}
404-
405-
memmove(dst, comp_start, comp_len);
406-
dst += comp_len;
407-
next:
408-
comp_start = comp_end;
409-
}
410-
411-
if (dst == buf)
412-
*dst++ = '/';
413-
414-
*dst = '\0';
415-
return dst - buf;
416-
}
417-
418379
int normalize_path_copy(char *dst, const char *src)
419380
{
420381
char *dst0;

0 commit comments

Comments
 (0)