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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
 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


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]