Skip to content

Commit 61ca378

Browse files
committed
Merge branch 'jk/push-config'
Restructure "git push" codepath to make it easier to add new configuration bits and then add push.followTags configuration that turns --follow-tags option on by default. * jk/push-config: push: allow --follow-tags to be set by config push.followTags cmd_push: pass "flags" pointer to config callback cmd_push: set "atomic" bit directly git_push_config: drop cargo-culted wt_status pointer
2 parents aa65b86 + a8bc269 commit 61ca378

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

Documentation/config.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,6 +2111,12 @@ new default).
21112111

21122112
--
21132113

2114+
push.followTags::
2115+
If set to true enable '--follow-tags' option by default. You
2116+
may override this configuration at time of push by specifying
2117+
'--no-follow-tags'.
2118+
2119+
21142120
rebase.stat::
21152121
Whether to show a diffstat of what changed upstream since the last
21162122
rebase. False by default.

Documentation/git-push.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ already exists on the remote side.
128128
Push all the refs that would be pushed without this option,
129129
and also push annotated tags in `refs/tags` that are missing
130130
from the remote but are pointing at commit-ish that are
131-
reachable from the refs being pushed.
131+
reachable from the refs being pushed. This can also be specified
132+
with configuration variable 'push.followTags'. For more
133+
information, see 'push.followTags' in linkgit:git-config[1].
134+
132135

133136
--signed::
134137
GPG-sign the push request to update refs on the receiving

builtin/push.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -473,21 +473,29 @@ static int option_parse_recurse_submodules(const struct option *opt,
473473

474474
static int git_push_config(const char *k, const char *v, void *cb)
475475
{
476-
struct wt_status *s = cb;
476+
int *flags = cb;
477477
int status;
478478

479479
status = git_gpg_config(k, v, NULL);
480480
if (status)
481481
return status;
482-
return git_default_config(k, v, s);
482+
483+
if (!strcmp(k, "push.followtags")) {
484+
if (git_config_bool(k, v))
485+
*flags |= TRANSPORT_PUSH_FOLLOW_TAGS;
486+
else
487+
*flags &= ~TRANSPORT_PUSH_FOLLOW_TAGS;
488+
return 0;
489+
}
490+
491+
return git_default_config(k, v, NULL);
483492
}
484493

485494
int cmd_push(int argc, const char **argv, const char *prefix)
486495
{
487496
int flags = 0;
488497
int tags = 0;
489498
int rc;
490-
int atomic = 0;
491499
const char *repo = NULL; /* default repository */
492500
struct option options[] = {
493501
OPT__VERBOSITY(&verbosity),
@@ -519,12 +527,12 @@ int cmd_push(int argc, const char **argv, const char *prefix)
519527
OPT_BIT(0, "follow-tags", &flags, N_("push missing but relevant tags"),
520528
TRANSPORT_PUSH_FOLLOW_TAGS),
521529
OPT_BIT(0, "signed", &flags, N_("GPG sign the push"), TRANSPORT_PUSH_CERT),
522-
OPT_BOOL(0, "atomic", &atomic, N_("request atomic transaction on remote side")),
530+
OPT_BIT(0, "atomic", &flags, N_("request atomic transaction on remote side"), TRANSPORT_PUSH_ATOMIC),
523531
OPT_END()
524532
};
525533

526534
packet_trace_identity("push");
527-
git_config(git_push_config, NULL);
535+
git_config(git_push_config, &flags);
528536
argc = parse_options(argc, argv, prefix, options, push_usage, 0);
529537

530538
if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
@@ -535,9 +543,6 @@ int cmd_push(int argc, const char **argv, const char *prefix)
535543
if (tags)
536544
add_refspec("refs/tags/*");
537545

538-
if (atomic)
539-
flags |= TRANSPORT_PUSH_ATOMIC;
540-
541546
if (argc > 0) {
542547
repo = argv[0];
543548
set_refspecs(argv + 1, argc - 1, repo);

contrib/completion/git-completion.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,6 +2186,7 @@ _git_config ()
21862186
pull.octopus
21872187
pull.twohead
21882188
push.default
2189+
push.followTags
21892190
rebase.autosquash
21902191
rebase.stat
21912192
receive.autogc

0 commit comments

Comments
 (0)