git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [GSoC][PATCH v2 2/2] credential-cache: use XDG_CACHE_HOME for socket

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 13, 2017, 21:52 UTC
Message-ID
<xmqqa88orgjd.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170313204355.56559-2-lehmacdj@gmail.com>
Devin Lehmacher <lehmacdj@gmail.com> writes:
> git-credential-cache will now use a socket following the XDG base path
> specification by default. This increases consistency with other
> applications and helps keep clutter out of users' home directories.

We tend to write our log messages in imperative mood, as if you are giving an order to the codebase to "be like so" (alternatively, you can read them as if you are giving an order to the maintainer of the code to "make these changes").

	We have been using ~/.git-credential-cache/socket as the
	location to store the UNIX socket to communicate with the
	credential daemon process.  In order to make it more
	consistent with other applications and reduce clutter in the
	home directory, move it to $XDG_CACHE_HOME/git/credential/socket,
	which matches what XDG base path specification suggests.

Similarly for the other two paragraphs. Instead of "We still check the old location ...", just "Check the old location ...", etc.

> If there is not a socket at that location we create a new one at
> $XDG_CACHE_HOME/git/credential/socket. This complies with the XDG
> standard and good for the reasons previously mentioned. 

And the second sentence can go; you already said why you think XDG_CACHE_HOME is a good idea.

> We use the
> subdirectory credential/ in case we later want to store other files
> under $XDG_CACHE_HOME/git/ and to make the purpose of the socket clear.

And this probably can disappear (or rolled into the first paragraph, if we really want; personally I think it is obvious why we want the extra "credential" directory under "git" there).

> I also change to documentation to reflect the new default socket
> location.

This probably does not have to be said, as it is obvious from the diffstat.

Missing sign-off.
Show 16 quoted lines
> ---
>  Documentation/git-credential-cache.txt |  3 ++-
>  credential-cache.c                     | 16 +++++++++++++++-
>  2 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-credential-cache.txt b/Documentation/git-credential-cache.txt
> index 96208f822..4b9db3856 100644
> --- a/Documentation/git-credential-cache.txt
> +++ b/Documentation/git-credential-cache.txt
> @@ -34,7 +34,8 @@ OPTIONS
>  
>  	Use `<path>` to contact a running cache daemon (or start a new
>  	cache daemon if one is not started). Defaults to
> -	`~/.git-credential-cache/socket`. If your home directory is on a
> +	`~/.git-credential-cache/socket` if it exists and otherwise
> +    `$XDG_CACHE_HOME/git/credential/socket`. If your home directory is on a
There is a funny indentation here.
Show 17 quoted lines
>  	network-mounted filesystem, you may need to change this to a
>  	local filesystem. You must specify an absolute path.
>  
> diff --git a/credential-cache.c b/credential-cache.c
> index cc8a6ee19..db1343b46 100644
> --- a/credential-cache.c
> +++ b/credential-cache.c
> @@ -83,6 +83,20 @@ static void do_cache(const char *socket, const char *action, int timeout,
>  	strbuf_release(&buf);
>  }
>  
> +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))

Don't we want to make sure that this path _is_ a socket? In general I think file_exists() is a poor choice to use here (the existing use are all about having a regular file there, and its definition may be later tightened from "does lstat() succeed?" to something a bit more sensible, and FIFO may start failing the updated test.

Thanks.
Previous: Devin LehmacherNext: Devin Lehmacher
Message 10 of 54 in “Move ~/.git-credential-cache to ~/.cache/git”
  1. Devin LehmacherMar 13, 2017
  2. [GSoC][PATCH 1/3] path.c: Add xdg_cache_home to get paths under XDG_CACHE_HOMEDevin Lehmacher, Mar 13, 2017
  3. Jeff KingMar 13, 2017
  4. Devin LehmacherMar 13, 2017
  5. [GSoC][PATCH 3/3] Update documentation to reflect new socket locationDevin Lehmacher, Mar 13, 2017
  6. Junio C HamanoMar 13, 2017
  7. [GSoC][PATCH v2 2/2] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 13, 2017
  8. [GSoC][PATCH v2 1/2] path.c: add xdg_cache_homeDevin Lehmacher, Mar 13, 2017
  9. [GSoC][PATCH v2 2/2] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 13, 2017
  10. Junio C HamanoMar 13, 2017
  11. [GSoC][PATCH/RFC v3 0/3] Fix commit messages, check if socket is socketDevin Lehmacher, Mar 14, 2017
  12. [GSoC][PATCH/RFC v3 3/3] credential-cache: only use user_socket if a socketDevin Lehmacher, Mar 14, 2017
  13. Devin LehmacherMar 14, 2017
  14. Brandon WilliamsMar 14, 2017
  15. Devin LehmacherMar 14, 2017
  16. Brandon WilliamsMar 14, 2017
  17. Junio C HamanoMar 14, 2017
  18. Junio C HamanoMar 14, 2017
  19. Devin LehmacherMar 14, 2017
  20. [GSoC][PATCH v4 0/4] Moving credential-cache socket to xdg pathDevin Lehmacher, Mar 16, 2017
  21. [GSoC][PATCH v4 1/4] path.c: add xdg_cache_homeDevin Lehmacher, Mar 16, 2017
  22. [GSoC][PATCH v4 4/4] credential-cache: add tests for XDG functionalityDevin Lehmacher, Mar 16, 2017
  23. Junio C HamanoMar 16, 2017
  24. Jeff KingMar 16, 2017
  25. [GSoC][PATCH v5 1/3] path.c: add xdg_cache_homeDevin Lehmacher, Mar 17, 2017
  26. [GSoC][PATCH v5 2/3] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 17, 2017
  27. Ramsay JonesMar 17, 2017
  28. Devin LehmacherMar 17, 2017
  29. [GSoC][PATCH v5 3/3] credential-cache: add tests for XDG functionalityDevin Lehmacher, Mar 17, 2017
  30. Junio C HamanoMar 17, 2017
  31. [GSoC][PATCH v6 1/3] path.c: add xdg_cache_homeDevin Lehmacher, Mar 17, 2017
  32. [GSoC][PATCH v6 2/3] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 17, 2017
  33. Jeff KingMar 17, 2017
  34. [GSoC][PATCH v6 3/3] credential-cache: add tests for XDG functionalityDevin Lehmacher, Mar 17, 2017
  35. Jeff KingMar 17, 2017
  36. Jeff KingMar 17, 2017
  37. [GSoC][PATCH v4 2/4] dir: add directory_existsDevin Lehmacher, Mar 16, 2017
  38. Junio C HamanoMar 16, 2017
  39. Junio C HamanoMar 16, 2017
  40. [GSoC][PATCH v4 3/4] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 16, 2017
  41. Junio C HamanoMar 16, 2017
  42. Jeff KingMar 16, 2017
  43. [GSoC][PATCH/RFC v3 2/3] credential-cache: use XDG_CACHE_HOME for socketDevin Lehmacher, Mar 14, 2017
  44. Junio C HamanoMar 14, 2017
  45. [GSoC][PATCH/RFC v3 1/3] path.c: add xdg_cache_homeDevin Lehmacher, Mar 14, 2017
  46. Junio C HamanoMar 13, 2017
  47. [GSoC][PATCH 2/3] credential-cache.c: Make git use XDG_CACHE_HOME for credentialsDevin Lehmacher, Mar 13, 2017
  48. Junio C HamanoMar 13, 2017
  49. Jeff KingMar 13, 2017
  50. Junio C HamanoMar 13, 2017
  51. Devin LehmacherMar 13, 2017
  52. Devin LehmacherMar 13, 2017
  53. Junio C HamanoMar 13, 2017
  54. Jeff KingMar 13, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.