From: Okhuomon Ajayi Date: Mon, 16 Nov 2026 19:13:21 GMT Subject: [Outreachy PATCH v3] credential-store: add lockTimeout config option Message-ID: <20261116191321.28837-1-okhuomonajayi54@gmail.com> In-Reply-To: <20261016212216.58000-1-okhuomonajayi54@gmail.com> The other settings that retry taking a file lock are measured in milliseconds and do not put the unit in the name: rerere.lockTimeout, reftable.lockTimeout, core.filesRefLockTimeout, core.packedRefsTimeout, and core.configLockTimeout. credentialStore.lockTimeoutMS spells the unit out. Add credentialStore.lockTimeout as the matching name. Keep lockTimeoutMS as a deprecated synonym so existing configuration still works. The value is still milliseconds, which the documentation states. Signed-off-by: Okhuomon Ajayi --- Changes since v2: - Reword the message to say why the new name drops the unit. The other file-lock retries are milliseconds and do not put the unit in the name. - Rebased onto current master (7fb6055e67, The 20th batch). Documentation/config/credential.adoc | 5 +++- builtin/credential-store.c | 7 +++++- t/t0302-credential-store.sh | 35 ++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Documentation/config/credential.adoc b/Documentation/config/credential.adoc index 80a7c77772..6fa40560be 100644 --- a/Documentation/config/credential.adoc +++ b/Documentation/config/credential.adoc @@ -48,8 +48,11 @@ credential..*:: credentialCache.ignoreSIGHUP:: Tell git-credential-cache--daemon to ignore SIGHUP, instead of quitting. -credentialStore.lockTimeoutMS:: +credentialStore.lockTimeout:: The length of time, in milliseconds, for git-credential-store to retry when trying to lock the credentials file. A value of 0 means not to retry at all; -1 means to try indefinitely. Default is 1000 (i.e., retry for 1s). + +credentialStore.lockTimeoutMS (deprecated):: + This is a deprecated synonym for `credentialStore.lockTimeout`. diff --git a/builtin/credential-store.c b/builtin/credential-store.c index bc1453c6b2..afd2e4f3ce 100644 --- a/builtin/credential-store.c +++ b/builtin/credential-store.c @@ -67,7 +67,12 @@ static void rewrite_credential_file(const char *fn, struct credential *c, { int timeout_ms = 1000; - repo_config_get_int(the_repository, "credentialstore.locktimeoutms", &timeout_ms); + /* lockTimeoutMS is a deprecated synonym of lockTimeout. */ + if (repo_config_get_int(the_repository, "credentialstore.locktimeout", + &timeout_ms)) + repo_config_get_int(the_repository, + "credentialstore.locktimeoutms", + &timeout_ms); if (hold_lock_file_for_update_timeout(&credential_lock, fn, 0, timeout_ms) < 0) die_errno(_("unable to get credential storage lock in %d ms"), timeout_ms); if (extra) diff --git a/t/t0302-credential-store.sh b/t/t0302-credential-store.sh index c1cd60edd0..e1bbca3fcc 100755 --- a/t/t0302-credential-store.sh +++ b/t/t0302-credential-store.sh @@ -210,4 +210,39 @@ test_expect_success 'get: store file can contain empty/bogus lines' ' EOF ' +# Holding creds.lock makes the next store fail. The error reports the +# timeout that was actually used, so "in 0 ms" means that name won. +for v in lockTimeout lockTimeoutMS +do + test_expect_success "credentialStore.$v=0 gives up immediately" ' + test_when_finished "rm -f creds creds.lock" && + >"creds.lock" && + test_must_fail git -c credentialStore.$v=0 \ + credential-store --file=creds store 2>err <<-\EOF && + protocol=https + host=example.com + username=store-user + password=store-pass + EOF + test_grep "unable to get credential storage lock in 0 ms" err + ' +done + +# lockTimeout=0 must win over lockTimeoutMS=500: the error says +# "in 0 ms", not "in 500 ms". +test_expect_success 'credentialStore.lockTimeout wins when both are set' ' + test_when_finished "rm -f creds creds.lock" && + >"creds.lock" && + test_must_fail git \ + -c credentialStore.lockTimeout=0 \ + -c credentialStore.lockTimeoutMS=500 \ + credential-store --file=creds store 2>err <<-\EOF && + protocol=https + host=example.com + username=store-user + password=store-pass + EOF + test_grep "unable to get credential storage lock in 0 ms" err +' + test_done base-commit: 7fb6055e678f800320d8ab8cd8f201d9493d1ba0 -- 2.56.0