On Fri, Mar 17, 2017 at 08:36:33AM -0400, Devin Lehmacher wrote:
> Make git-credential-cache follow the XDG base path specification by
> default. This increases consistency with other applications and helps
> keep clutter out of users' home directories.
>
> Check the old socket location, ~/.git-credential-cache/, and use
> ~/.git-credential-cache/socket if that directory exists rather than
> forcing users who have used `git credential-cache` before to migrate to
> the new XDG compliant location.
> Otherwise use the socket $XDG_CACHE_HOME/git/credential/socket following
> XDG base path specification. Use the subdirectory credential/ in case
> other files are cached under $XDG_CACHE_HOME/git/ in the future and to
> make the socket's purpose clear.
Makes sense.
> +static char *get_socket_path(void)
> +{
> + struct stat sb;
> + char *old_dir, *socket;
> + old_dir = expand_user_path("~/.git-credential-cache");
> + if (old_dir && !stat(old_dir, &sb) && S_ISDIR(sb.st_mode))
> + socket = xstrfmt("%s/socket", old_dir);
> + else
> + socket = xdg_cache_home("credential/socket");
> + free(old_dir);
> + return socket;
> +}
The implementation looks nice and clean.
-Peff