Skip to content

Commit fd2d4c1

Browse files
committed
gpg-interface: lazily initialize and read the configuration
Instead of forcing the porcelain commands to always read the configuration variables related to the signing and verifying signatures, lazily initialize the necessary subsystem on demand upon the first use. This hopefully would make it more future-proof as we do not have to think and decide whether we should call git_gpg_config() in the git_config() callback for each command. A few git_config() callback functions that used to be custom callbacks are now just a thin wrapper around git_default_config(). We could further remove, git_FOO_config and replace calls to git_config(git_FOO_config) with git_config(git_default_config), but to make it clear which ones are affected and the effect is only the removal of git_gpg_config(), it is vastly preferred not to do such a change in this step (they can be done on top once the dust settled). Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7876265 commit fd2d4c1

17 files changed

+33
-57
lines changed

builtin/am.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,12 +2314,6 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
23142314

23152315
static int git_am_config(const char *k, const char *v, void *cb UNUSED)
23162316
{
2317-
int status;
2318-
2319-
status = git_gpg_config(k, v, NULL);
2320-
if (status)
2321-
return status;
2322-
23232317
return git_default_config(k, v, NULL);
23242318
}
23252319

builtin/commit-tree.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ static void new_parent(struct commit *parent, struct commit_list **parents_p)
3939

4040
static int commit_tree_config(const char *var, const char *value, void *cb)
4141
{
42-
int status = git_gpg_config(var, value, NULL);
43-
if (status)
44-
return status;
4542
return git_default_config(var, value, cb);
4643
}
4744

builtin/commit.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,6 @@ int cmd_status(int argc, const char **argv, const char *prefix)
16001600
static int git_commit_config(const char *k, const char *v, void *cb)
16011601
{
16021602
struct wt_status *s = cb;
1603-
int status;
16041603

16051604
if (!strcmp(k, "commit.template"))
16061605
return git_config_pathname(&template_file, k, v);
@@ -1620,9 +1619,6 @@ static int git_commit_config(const char *k, const char *v, void *cb)
16201619
return 0;
16211620
}
16221621

1623-
status = git_gpg_config(k, v, NULL);
1624-
if (status)
1625-
return status;
16261622
return git_status_config(k, v, s);
16271623
}
16281624

builtin/log.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,6 @@ static int git_log_config(const char *var, const char *value, void *cb)
601601
return 0;
602602
}
603603

604-
if (git_gpg_config(var, value, cb) < 0)
605-
return -1;
606604
return git_diff_ui_config(var, value, cb);
607605
}
608606

builtin/merge.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,6 @@ static int git_merge_config(const char *k, const char *v, void *cb)
659659
}
660660

661661
status = fmt_merge_msg_config(k, v, cb);
662-
if (status)
663-
return status;
664-
status = git_gpg_config(k, v, NULL);
665662
if (status)
666663
return status;
667664
return git_diff_ui_config(k, v, cb);

builtin/pull.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,6 @@ static enum rebase_type config_get_rebase(int *rebase_unspecified)
359359
*/
360360
static int git_pull_config(const char *var, const char *value, void *cb)
361361
{
362-
int status;
363-
364362
if (!strcmp(var, "rebase.autostash")) {
365363
config_autostash = git_config_bool(var, value);
366364
return 0;
@@ -372,10 +370,6 @@ static int git_pull_config(const char *var, const char *value, void *cb)
372370
check_trust_level = 0;
373371
}
374372

375-
status = git_gpg_config(var, value, cb);
376-
if (status)
377-
return status;
378-
379373
return git_default_config(var, value, cb);
380374
}
381375

builtin/push.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,6 @@ static int git_push_config(const char *k, const char *v, void *cb)
502502
{
503503
const char *slot_name;
504504
int *flags = cb;
505-
int status;
506-
507-
status = git_gpg_config(k, v, NULL);
508-
if (status)
509-
return status;
510505

511506
if (!strcmp(k, "push.followtags")) {
512507
if (git_config_bool(k, v))

builtin/receive-pack.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
133133
{
134134
int status = parse_hide_refs_config(var, value, "receive", &hidden_refs);
135135

136-
if (status)
137-
return status;
138-
139-
status = git_gpg_config(var, value, NULL);
140136
if (status)
141137
return status;
142138

builtin/send-pack.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ static void print_helper_status(struct ref *ref)
130130

131131
static int send_pack_config(const char *k, const char *v, void *cb)
132132
{
133-
git_gpg_config(k, v, NULL);
134-
135133
if (!strcmp(k, "push.gpgsign")) {
136134
const char *value;
137135
if (!git_config_get_value("push.gpgsign", &value)) {

builtin/tag.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ static const char tag_template_nocleanup[] =
180180

181181
static int git_tag_config(const char *var, const char *value, void *cb)
182182
{
183-
int status;
184-
185183
if (!strcmp(var, "tag.gpgsign")) {
186184
config_sign_tag = git_config_bool(var, value);
187185
return 0;
@@ -194,9 +192,6 @@ static int git_tag_config(const char *var, const char *value, void *cb)
194192
return 0;
195193
}
196194

197-
status = git_gpg_config(var, value, cb);
198-
if (status)
199-
return status;
200195
if (!strcmp(var, "tag.forcesignannotated")) {
201196
force_sign_annotate = git_config_bool(var, value);
202197
return 0;

0 commit comments

Comments
 (0)