summaryrefslogtreecommitdiff
path: root/credential-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-24 13:07:34 -0700
committerJunio C Hamano <gitster@pobox.com>2017-03-24 13:07:34 -0700
commit78cf8efec34c419ecea86bc8d1fe47ec0b51ba37 (patch)
treee93e9c07cd61311d63aa589cfd2452662dfcafb5 /credential-cache.c
parentf364f02724d6ce4c64fae85a86e0452b5634ddf8 (diff)
parent612c49e94d5c761bd9fc4752283b82786c23856a (diff)
downloadgit-78cf8efec34c419ecea86bc8d1fe47ec0b51ba37.tar.gz
Merge branch 'dl/credential-cache-socket-in-xdg-cache'
The default location "~/.git-credential-cache/socket" for the socket used to communicate with the credential-cache daemon has been moved to "~/.cache/git/credential/socket". * dl/credential-cache-socket-in-xdg-cache: credential-cache: add tests for XDG functionality credential-cache: use XDG_CACHE_HOME for socket path.c: add xdg_cache_home
Diffstat (limited to 'credential-cache.c')
-rw-r--r--credential-cache.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/credential-cache.c b/credential-cache.c
index cc8a6ee192..3cbd420019 100644
--- a/credential-cache.c
+++ b/credential-cache.c
@@ -83,6 +83,19 @@ static void do_cache(const char *socket, const char *action, int timeout,
strbuf_release(&buf);
}
+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;
+}
+
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");