Web lists-archives.com

Re: [GSoC][PATCH/RFC v3 3/3] credential-cache: only use user_socket if a socket




Devin Lehmacher <lehmacdj@xxxxxxxxx> writes:

> diff --git a/credential-cache.c b/credential-cache.c
> index db1343b46..63236adc2 100644
> --- a/credential-cache.c
> +++ b/credential-cache.c
> @@ -83,12 +83,18 @@ static void do_cache(const char *socket, const char *action, int timeout,
>  	strbuf_release(&buf);
>  }
>  
> +static int is_socket(char *path) {
> +	struct stat sb;
> +	int ret = lstat(path, &sb);
> +	return ret && S_IFSOCK(sb.st_mode);
> +}
> +
>  static char *get_socket_path(void) {
>  	char *home_socket;
>  
>  	home_socket = expand_user_path("~/.git-credential-cache/socket");
>  	if (home_socket) {
> -		if (file_exists(home_socket))
> +		if (is_socket(home_socket))

This should be done as part of 2/3, no?  It does not make sense to
add 2/3 and then immediately say "oops, the check in 2/3 is wrong,
and let's update it like so".