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 <jrnie...@gmail.com>
---
 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);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to