git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Luis Ressel <aranea@aixah.de>
To: git@vger.kernel.org
Subject: [PATCH] Add XDG support to the credential-store helper
Date: Thu, 5 Mar 2015 21:53:06 +0100	[thread overview]
Message-ID: <20150305215306.65aab57c@gentp.lnet> (raw)
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

  reply	other threads:[~2015-03-05 21:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-05 20:51 [GSoC microproject] Add XDG support to the credential-store helper Luis Ressel
2015-03-05 20:53 ` Luis Ressel [this message]
2015-03-05 22:10 ` Junio C Hamano
2015-03-05 22:38 ` Christian Couder
2015-03-05 23:15   ` Luis Ressel
2015-03-05 23:41     ` Luis Ressel
2015-03-06  8:04       ` Paul Tan
2015-03-06 17:28         ` Matthieu Moy
2015-03-06 19:21           ` Paul Tan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150305215306.65aab57c@gentp.lnet \
    --to=aranea@aixah.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).