Web lists-archives.com

Re: [GSoC][PATCH 2/3] credential-cache.c: Make git use XDG_CACHE_HOME for credentials




Devin Lehmacher <lehmacdj@xxxxxxxxx> writes:

> +static char* get_socket_path(void) {
> +	char *home_socket;
> +
> +	home_socket = expand_user_path("~/.git_credential_cache/socket");

The typo on this line guarantees that nobody will retain the current
location and will be migrated forcibly to the new xdg place ;-)

> +	if (home_socket)
> +		if (file_exists(home_socket))
> +			return home_socket;
> +		else
> +			free(home_socket);
> +
> +	return xdg_cache_home("credential/socket");
> +}

I somehow feel that the order of precedence should be the other way
around, though.  

If somebody really wants to use the xdg location and has a socket
already there, using that existing socket would be the right thing
to do.  However, when neither ~/.git-credential-cache/socket nor
~/.cache/git/socket exists, why should we prefer the latter over the
former?

>  int cmd_main(int argc, const char **argv)
>  {
>  	char *socket_path = NULL;
> @@ -106,7 +119,7 @@ int cmd_main(int argc, const char **argv)
>  	op = argv[0];
>  
>  	if (!socket_path)
> -		socket_path = expand_user_path("~/.git-credential-cache/socket");
> +		socket_path = get_socket_path();
>  	if (!socket_path)
>  		die("unable to find a suitable socket path; use --socket");