Re: [GSoC][PATCH/RFC v3 3/3] credential-cache: only use user_socket if a socket
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 14, 2017, 01:52 UTC
- Message-ID
- <xmqq8to8lj59.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20170314003246.71586-4-lehmacdj@gmail.com>
Devin Lehmacher <lehmacdj@gmail.com> writes:
Show 21 quoted lines
> 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".