Subject: [PATCH 08/14] credentials: use message from lockfile API when locking ~/.git-credentials fails

From: Jonathan Nieder <[email-masked]>
Date: Tue, 2 Dec 2014 21:20:44 -0800

If writing $HOME/.git-credentials.lock (or locking another file
specified with the --file option) fails due to the lock file already
existing, chances are that it is because another git process already
locked the file.  Use the message from the lockfile API that says so,
to help the user to look for running git processes and remove the
stray .lock file when it is safe.

Signed-off-by: Jonathan Nieder <[email-masked]>
---
 credential-store.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/credential-store.c b/credential-store.c
index d435514..cd71156 100644
--- a/credential-store.c
+++ b/credential-store.c
@@ -55,8 +55,8 @@ static void print_line(struct strbuf *buf)
 static void rewrite_credential_file(const char *fn, struct credential *c,
 				    struct strbuf *extra)
 {
-	if (hold_lock_file_for_update(&credential_lock, fn, 0) < 0)
-		die_errno("unable to get credential storage lock");
+	hold_lock_file_for_update(&credential_lock, fn,
+				  LOCK_DIE_ON_ERROR | LOCK_OUTSIDE_REPOSITORY);
 	if (extra)
 		print_line(extra);
 	parse_credential_file(fn, c, NULL, print_line);