On Thu, Mar 16, 2017 at 09:20:29AM -0700, Junio C Hamano wrote:
> static char *get_socket_path(void)
> {
> struct stat st;
> char *path;
>
> path = expand_user_path("~/.git-credential-cache");
> if (path && !stat(path, &st) && S_ISDIR(st.st_mode))) {
> free(path);
> path = expand_user_path("~/.git-credential-cache/socket");
> } else {
> path = xdg_cache_home("credential/socket");
> }
> return path;
> }
>
> The duplication of "~/.git-credential-cache" bothers me somewhat and
> perhaps people can suggest better ways to get rid of the dup.
Maybe:
path = expand_user_path("~/.git-credential-cache");
if (path && !stat(path, &st) && S_ISDIR(st.st_mode))) {
char *new_path = xstrfmt("%s/socket", path);
free(path);
path = new_path;
} else ...
-Peff