From: "Koji Nakamaru via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Bo Anderson <mail@boanderson.me>, Jeff King <peff@peff.net>,
"brian m. carlson" <sandals@crustytoothpaste.net>,
Koji Nakamaru <koji.nakamaru@gree.net>,
Koji Nakamaru <koji.nakamaru@gree.net>
Subject: [PATCH v2 2/2] osxkeychain: state[] seen=1 to skip unnecessary store operations
Date: Sat, 11 May 2024 11:55:42 +0000 [thread overview]
Message-ID: <1f57718abff1d0e234c4145e833424da7be79311.1715428542.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1729.v2.git.1715428542.gitgitgadget@gmail.com>
From: Koji Nakamaru <koji.nakamaru@gree.net>
Records whether credentials come from get operations and skips
unnecessary store operations by utilizing the state[] feature, as
suggested by brian m. carlson.
Signed-off-by: Koji Nakamaru <koji.nakamaru@gree.net>
---
.../osxkeychain/git-credential-osxkeychain.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/contrib/credential/osxkeychain/git-credential-osxkeychain.c b/contrib/credential/osxkeychain/git-credential-osxkeychain.c
index 0884db48d0a..6ce22a28ed7 100644
--- a/contrib/credential/osxkeychain/git-credential-osxkeychain.c
+++ b/contrib/credential/osxkeychain/git-credential-osxkeychain.c
@@ -12,6 +12,7 @@ static CFStringRef username;
static CFDataRef password;
static CFDataRef password_expiry_utc;
static CFDataRef oauth_refresh_token;
+static int state_seen;
static void clear_credential(void)
{
@@ -171,6 +172,9 @@ static OSStatus find_internet_password(void)
CFRelease(item);
+ write_item("capability[]", "state", strlen("state"));
+ write_item("state[]", "osxkeychain:seen=1", strlen("osxkeychain:seen=1"));
+
out:
CFRelease(attrs);
@@ -284,6 +288,9 @@ static OSStatus add_internet_password(void)
CFDictionaryRef attrs;
OSStatus result;
+ if (state_seen)
+ return errSecSuccess;
+
/* Only store complete credentials */
if (!protocol || !host || !username || !password)
return -1;
@@ -395,6 +402,10 @@ static void read_credential(void)
oauth_refresh_token = CFDataCreate(kCFAllocatorDefault,
(UInt8 *)v,
strlen(v));
+ else if (!strcmp(buf, "state[]")) {
+ if (!strcmp(v, "osxkeychain:seen=1"))
+ state_seen = 1;
+ }
/*
* Ignore other lines; we don't know what they mean, but
* this future-proofs us when later versions of git do
--
gitgitgadget
next prev parent reply other threads:[~2024-05-11 11:55 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-10 8:07 [PATCH] osxkeychain: lock for exclusive execution Koji Nakamaru via GitGitGadget
2024-05-10 15:02 ` Bo Anderson
2024-05-10 20:01 ` Jeff King
2024-05-10 20:33 ` brian m. carlson
2024-05-10 22:07 ` Jeff King
2024-05-10 23:12 ` brian m. carlson
2024-05-10 20:40 ` Junio C Hamano
2024-05-10 22:09 ` Jeff King
2024-05-10 22:50 ` Junio C Hamano
[not found] ` <C0C8F71D-2A01-4C31-9EB6-AB31FA17C3AB@boanderson.me>
2024-05-10 18:26 ` Koji Nakamaru
2024-05-11 11:55 ` [PATCH v2 0/2] " Koji Nakamaru via GitGitGadget
2024-05-11 11:55 ` [PATCH v2 1/2] " Koji Nakamaru via GitGitGadget
2024-05-12 4:09 ` Junio C Hamano
2024-05-12 6:47 ` Koji Nakamaru
2024-05-11 11:55 ` Koji Nakamaru via GitGitGadget [this message]
2024-05-12 4:09 ` [PATCH v2 2/2] osxkeychain: state[] seen=1 to skip unnecessary store operations Junio C Hamano
2024-05-12 7:05 ` Koji Nakamaru
2024-05-15 19:21 ` [PATCH v3 0/2] osxkeychain: lock for exclusive execution Koji Nakamaru via GitGitGadget
2024-05-15 19:21 ` [PATCH v3 1/2] osxkeychain: exclusive lock to serialize execution of operations Koji Nakamaru via GitGitGadget
2024-05-15 19:21 ` [PATCH v3 2/2] osxkeychain: state to skip unnecessary store operations Koji Nakamaru via GitGitGadget
2024-05-15 19:41 ` [PATCH v3 0/2] osxkeychain: lock for exclusive execution Koji Nakamaru
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1f57718abff1d0e234c4145e833424da7be79311.1715428542.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=koji.nakamaru@gree.net \
--cc=mail@boanderson.me \
--cc=peff@peff.net \
--cc=sandals@crustytoothpaste.net \
/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.
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).