Re: [GSoC][PATCH 2/3] credential-cache.c: Make git use XDG_CACHE_HOME for credentials
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 13, 2017, 18:09 UTC
- Message-ID
- <xmqqtw6xrquw.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20170313172232.96678-3-lehmacdj@gmail.com>
Devin Lehmacher <lehmacdj@gmail.com> 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 ;-)
Show 8 quoted lines
> + 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?
Show 11 quoted lines
> 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");