git-2.22.0/lockfile.c
/*
 * path contains a path that might be a symlink.
 *
 * If path is a symlink, attempt to overwrite it with a path to the
 * real file or directory (which may or may not exist), following a
 * chain of symlinks if necessary.  Otherwise, leave path unmodified.
 *
 * This is a best-effort routine.  If an error occurs, path will
 * either be left unmodified or will name a different symlink in a
 * symlink chain that started with the original path.
 */
path contains a path that might be a symlink.
If path is a symlink, attempt to overwrite it with a path to the
real file or directory (which may or may not exist), following a
chain of symlinks if necessary.  Otherwise, leave path unmodified.

This is a best-effort routine.  If an error occurs, path will
either be left unmodified or will name a different symlink in a
symlink chain that started with the original path.
path contains a path that might be a symlink . If path is a symlink attempt to overwrite it with a path to the real file or directory ( which may or may not exist ) following a chain of symlinks if necessary . Otherwise leave path unmodified . This is a best - effort routine . If an error occurs path will either be left unmodified or will name a different symlink in a symlink chain that started with the original path .
static void resolve_symlink(struct strbuf *path)
{
	int depth = MAXDEPTH;
	static struct strbuf link = STRBUF_INIT;
	while (depth--) {
		if (strbuf_readlink(&link, path->buf, path->len) < 0)
			break;
		if (is_absolute_path(link.buf))
			strbuf_reset(path);
		else
			trim_last_path_component(path);
		strbuf_addbuf(path, &link);
	}
	strbuf_reset(&link);
}
static void resolve_symlink ( struct strbuf * path ) { int depth = MAXDEPTH ; static struct strbuf link = STRBUF_INIT ; while ( depth -- ) { if ( strbuf_readlink ( & link , path -> buf , path -> len ) < 0 ) break ; if ( is_absolute_path ( link . buf ) ) strbuf_reset ( path ) ; else trim_last_path_component ( path ) ; strbuf_addbuf ( path , & link ) ; } strbuf_reset ( & link ) ; }
path contains a path that might be a symlink.
path contains a path that might be a symlink .
/* absolute path simply replaces p */ /*
			 * link is a relative path, so replace the
			 * last element of p with it.
			 */