Skip to contentSkip to conversation

am: configure gpg at startup

PATCH In review Renee Margaret McConahy 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 am: configure gpg at startup

The new builtin am ignores the user.signingkey variable: gpg is being called with the committer details as the key ID, which may not be correct. git_gpg_config is responsible for handling that variable and is expected to be called on initialization by any modules that use gpg.

Perhaps git_gpg_config's functionality ought to be merged into git_default_config, but this is simpler and in keeping with the current practice.

---
 builtin/am.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
builtin/am.c +13 -1
index 4f77e07..f0b0ffd 100644
@@ -2208,6 +2208,18 @@ enum resume_mode {
 	RESUME_ABORT
 };
 
+static int git_am_config(const char *k, const char *v, void *cb)
+{
+	int *flags = cb;
+	int status;
+
+	status = git_gpg_config(k, v, NULL);
+	if (status)
+		return status;
+
+	return git_default_config(k, v, NULL);
+}
+
 int cmd_am(int argc, const char **argv, const char *prefix)
 {
 	struct am_state state;
@@ -2308,7 +2320,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 		OPT_END()
 	};
 
-	git_config(git_default_config, NULL);
+	git_config(git_am_config, NULL);
 
 	am_state_init(&state, git_path("rebase-apply"));
 
Signature · 1 line
2.6.0
#1 lore raw
Quoted 16 lines · Renee Margaret McConahy

The new builtin am ignores the user.signingkey variable: gpg is being called with the committer details as the key ID, which may not be correct. git_gpg_config is responsible for handling that variable and is expected to be called on initialization by any modules that use gpg.

Perhaps git_gpg_config's functionality ought to be merged into git_default_config, but this is simpler and in keeping with the current practice.

---

builtin/am.c +0 -0
index 4f77e07..f0b0ffd 100644

builtin/am.c enum resume_mode { · line 2213

Quoted 6 lines
builtin/am.c +3 -0
@@ -2208,6 +2208,18 @@ enum resume_mode {
        RESUME_ABORT
 };
 
+static int git_am_config(const char *k, const char *v, void *cb)
+{
+       int *flags = cb;

'flags' seems to be unused.

Quoted 23 lines
builtin/am.c +10 -2
+       int status;
+
+       status = git_gpg_config(k, v, NULL);
+       if (status)
+               return status;
+
+       return git_default_config(k, v, NULL);
+}
+
 int cmd_am(int argc, const char **argv, const char *prefix)
 {
        struct am_state state;
@@ -2308,7 +2320,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
                OPT_END()
        };
 
-       git_config(git_default_config, NULL);
+       git_config(git_am_config, NULL);
 
        am_state_init(&state, git_path("rebase-apply"));
 
--

2.6.0

#2 lore raw
In reply to Renee Margaret McConahy
Quoted 11 lines · Renee Margaret McConahy

The new builtin am ignores the user.signingkey variable: gpg is being called with the committer details as the key ID, which may not be correct. git_gpg_config is responsible for handling that variable and is expected to be called on initialization by any modules that use gpg.

Perhaps git_gpg_config's functionality ought to be merged into git_default_config, but this is simpler and in keeping with the current practice.

---

Thanks.

I'd remove the unused "flags" (already pointed out by somebody, I think), but otherwise the change looks sensible.

Quoted 34 lines
 builtin/am.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
builtin/am.c +13 -1
index 4f77e07..f0b0ffd 100644
@@ -2208,6 +2208,18 @@ enum resume_mode {
 	RESUME_ABORT
 };
 
+static int git_am_config(const char *k, const char *v, void *cb)
+{
+	int *flags = cb;
+	int status;
+
+	status = git_gpg_config(k, v, NULL);
+	if (status)
+		return status;
+
+	return git_default_config(k, v, NULL);
+}
+
 int cmd_am(int argc, const char **argv, const char *prefix)
 {
 	struct am_state state;
@@ -2308,7 +2320,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 		OPT_END()
 	};
 
-	git_config(git_default_config, NULL);
+	git_config(git_am_config, NULL);
 
 	am_state_init(&state, git_path("rebase-apply"));
#3 lore raw

PATCH v2 1/1 am: configure gpg at startup

The new builtin am ignores the user.signingkey variable: gpg is being called with the committer details as the key ID, which may not be correct. git_gpg_config is responsible for handling that variable and is expected to be called on initialization by any modules that use gpg.

Perhaps git_gpg_config's functionality ought to be merged into git_default_config, but this is simpler and in keeping with the current practice.

---
Oops, my bad. Thanks.

 builtin/am.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
builtin/am.c +12 -1
index 4f77e07..3bd4fd7 100644
@@ -2208,6 +2208,17 @@ enum resume_mode {
 	RESUME_ABORT
 };
 
+static int git_am_config(const char *k, const char *v, void *cb)
+{
+	int status;
+
+	status = git_gpg_config(k, v, NULL);
+	if (status)
+		return status;
+
+	return git_default_config(k, v, NULL);
+}
+
 int cmd_am(int argc, const char **argv, const char *prefix)
 {
 	struct am_state state;
@@ -2308,7 +2319,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 		OPT_END()
 	};
 
-	git_config(git_default_config, NULL);
+	git_config(git_am_config, NULL);
 
 	am_state_init(&state, git_path("rebase-apply"));
 
Signature · 1 line
2.5.3