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

[PATCH] Add XDG support to the credential-store helper

From
Luis Ressel <aranea@aixah.de>
Date
Mar 5, 2015, 20:53 UTC
Message-ID
<20150305215306.65aab57c@gentp.lnet>
In-Reply-To
<20150305215146.394caa71@gentp.lnet>

credential-store will use ${XDG_CONFIG_HOME}/credentials to store credentials if this file already exists and no --file option is given. Otherwise it'll fall back to ~/.git-credentials (status quo).

Signed-off-by: Luis Ressel <aranea@aixah.de>
---
 Documentation/git-credential-store.txt | 4 +++-
 credential-store.c                     | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-credential-store.txt
b/Documentation/git-credential-store.txt index bc97071..cab8f72 100644
--- a/Documentation/git-credential-store.txt
+++ b/Documentation/git-credential-store.txt
@@ -34,7 +34,9 @@ OPTIONS
 	Use `<path>` to store credentials. The file will have its
 	filesystem permissions set to prevent other users on the system
 	from reading it, but will not be encrypted or otherwise
-	protected. Defaults to `~/.git-credentials`.
+	protected. Defaults to `~/.git-credentials` or
+	`$XDG_CONFIG_HOME/git/credentials` if the latter exists
+	($XDG_CONFIG_HOME defaults to ~/.config).
 
 EXAMPLES
 --------
diff --git a/credential-store.c b/credential-store.c
index 925d3f4..9720b42 100644
--- a/credential-store.c
+++ b/credential-store.c
@@ -138,6 +138,8 @@ int main(int argc, char **argv)
 	op = argv[0];
 
 	if (!file)
+		home_config_paths(NULL, &file, "credentials");
+	if (!file || access(file, R_OK|W_OK))
 		file = expand_user_path("~/.git-credentials");
 	if (!file)
 		die("unable to set up default path; use --file");
-- 
2.3.1
Previous: Luis ResselNext: Junio C Hamano
Message 2 of 9 in “[GSoC microproject] Add XDG support to the credential-store helper”
  1. Luis ResselMar 5, 2015
  2. Add XDG support to the credential-store helperLuis Ressel, Mar 5, 2015
  3. Junio C HamanoMar 5, 2015
  4. Christian CouderMar 5, 2015
  5. Luis ResselMar 5, 2015
  6. Luis ResselMar 5, 2015
  7. Paul TanMar 6, 2015
  8. Matthieu MoyMar 6, 2015
  9. Paul TanMar 6, 2015

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.