git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] push: allow --follow-tags' to be set by config push.followTags
@ 2015-02-15 23:39 Dave Olszewski
  2015-02-16  0:01 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Olszewski @ 2015-02-15 23:39 UTC (permalink / raw)
  To: git, gitster; +Cc: Dave Olszewski

Signed-off-by: Dave Olszewski <cxreg@pobox.com>
---
 Documentation/config.txt               | 3 +++
 Documentation/git-push.txt             | 5 ++++-
 cache.h                                | 1 +
 config.c                               | 5 +++++
 contrib/completion/git-completion.bash | 1 +
 environment.c                          | 1 +
 transport.c                            | 2 +-
 7 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index ae6791d..cdb8a99 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2079,6 +2079,9 @@ new default).
 
 --
 
+push.followTags::
+	If set to true enable '--follow-tags' option by default.
+
 rebase.stat::
 	Whether to show a diffstat of what changed upstream since the last
 	rebase. False by default.
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index ea97576..caa187b 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -128,7 +128,10 @@ already exists on the remote side.
 	Push all the refs that would be pushed without this option,
 	and also push annotated tags in `refs/tags` that are missing
 	from the remote but are pointing at commit-ish that are
-	reachable from the refs being pushed.
+	reachable from the refs being pushed.  This can also be specified
+	with configuration variable 'push.followTags'.  For more
+	information, see 'push.followTags' in linkgit:git-config[1].
+
 
 --signed::
 	GPG-sign the push request to update refs on the receiving
diff --git a/cache.h b/cache.h
index f704af5..9318189 100644
--- a/cache.h
+++ b/cache.h
@@ -648,6 +648,7 @@ enum push_default_type {
 extern enum branch_track git_branch_track;
 extern enum rebase_setup_type autorebase;
 extern enum push_default_type push_default;
+extern int push_follow_tags;
 
 enum object_creation_mode {
 	OBJECT_CREATION_USES_HARDLINKS = 0,
diff --git a/config.c b/config.c
index e5e64dc..cb237cd 100644
--- a/config.c
+++ b/config.c
@@ -977,6 +977,11 @@ static int git_default_push_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp(var, "push.followtags")) {
+		push_follow_tags = git_config_bool(var, value);
+		return 0;
+	}
+
 	/* Add other config variables here and to Documentation/config.txt. */
 	return 0;
 }
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c21190d..cffb2b8 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2188,6 +2188,7 @@ _git_config ()
 		pull.octopus
 		pull.twohead
 		push.default
+		push.followTags
 		rebase.autosquash
 		rebase.stat
 		receive.autogc
diff --git a/environment.c b/environment.c
index 1ade5c9..aef9587 100644
--- a/environment.c
+++ b/environment.c
@@ -52,6 +52,7 @@ unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
 enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
 enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
+int push_follow_tags = 0;
 #ifndef OBJECT_CREATION_MODE
 #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
 #endif
diff --git a/transport.c b/transport.c
index 0694a7c..87cd657 100644
--- a/transport.c
+++ b/transport.c
@@ -1148,7 +1148,7 @@ int transport_push(struct transport *transport,
 			match_flags |= MATCH_REFS_MIRROR;
 		if (flags & TRANSPORT_PUSH_PRUNE)
 			match_flags |= MATCH_REFS_PRUNE;
-		if (flags & TRANSPORT_PUSH_FOLLOW_TAGS)
+		if ((flags & TRANSPORT_PUSH_FOLLOW_TAGS) || push_follow_tags)
 			match_flags |= MATCH_REFS_FOLLOW_TAGS;
 
 		if (match_push_refs(local_refs, &remote_refs,
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] push: allow --follow-tags' to be set by config push.followTags
  2015-02-15 23:39 [PATCH] push: allow --follow-tags' to be set by config push.followTags Dave Olszewski
@ 2015-02-16  0:01 ` Junio C Hamano
  2015-02-16  3:01   ` Dave Olszewski
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2015-02-16  0:01 UTC (permalink / raw)
  To: Dave Olszewski; +Cc: Git Mailing List

On Sun, Feb 15, 2015 at 3:39 PM, Dave Olszewski <cxreg@pobox.com> wrote:
> Signed-off-by: Dave Olszewski <cxreg@pobox.com>
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index ae6791d..cdb8a99 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -2079,6 +2079,9 @@ new default).
>
>  --
>
> +push.followTags::
> +       If set to true enable '--follow-tags' option by default.
> +

After setting this in your repository, does "git push --no-follow-tags" let
you override it if you want to do so for a single invocation?

If it does, the code is good but it should be documented here; if it
does not, it should be corrected and it should be documented here.

Thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Re: [PATCH] push: allow --follow-tags' to be set by config push.followTags
  2015-02-16  0:01 ` Junio C Hamano
@ 2015-02-16  3:01   ` Dave Olszewski
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Olszewski @ 2015-02-16  3:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

On Sun, 15 Feb 2015, Junio C Hamano wrote:

> On Sun, Feb 15, 2015 at 3:39 PM, Dave Olszewski <cxreg@pobox.com> wrote:
> > Signed-off-by: Dave Olszewski <cxreg@pobox.com>
> >
> > diff --git a/Documentation/config.txt b/Documentation/config.txt
> > index ae6791d..cdb8a99 100644
> > --- a/Documentation/config.txt
> > +++ b/Documentation/config.txt
> > @@ -2079,6 +2079,9 @@ new default).
> >
> >  --
> >
> > +push.followTags::
> > +       If set to true enable '--follow-tags' option by default.
> > +
> 
> After setting this in your repository, does "git push --no-follow-tags" let
> you override it if you want to do so for a single invocation?
> 
> If it does, the code is good but it should be documented here; if it
> does not, it should be corrected and it should be documented here.
> 
> Thanks.

Thanks for the feedback.  I was able to get this behavior by setting the
config value into the flags variable before parsing command line
options.  Hopefully this is acceptable practice.  Updated patch coming
shortly

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] push: allow --follow-tags to be set by config push.followTags
@ 2015-02-16  3:01 Dave Olszewski
  2015-02-16  5:20 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Olszewski @ 2015-02-16  3:01 UTC (permalink / raw)
  To: git, gitster; +Cc: Dave Olszewski

Signed-off-by: Dave Olszewski <cxreg@pobox.com>
---
 Documentation/config.txt               | 6 ++++++
 Documentation/git-push.txt             | 5 ++++-
 builtin/push.c                         | 5 +++++
 cache.h                                | 1 +
 config.c                               | 5 +++++
 contrib/completion/git-completion.bash | 1 +
 environment.c                          | 1 +
 transport.c                            | 2 +-
 8 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index ae6791d..e01d21c 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2079,6 +2079,12 @@ new default).
 
 --
 
+push.followTags::
+	If set to true enable '--follow-tags' option by default.  You
+	may override this configuration at time of push by specifying
+	'--no-follow-tags'.
+
+
 rebase.stat::
 	Whether to show a diffstat of what changed upstream since the last
 	rebase. False by default.
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index ea97576..caa187b 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -128,7 +128,10 @@ already exists on the remote side.
 	Push all the refs that would be pushed without this option,
 	and also push annotated tags in `refs/tags` that are missing
 	from the remote but are pointing at commit-ish that are
-	reachable from the refs being pushed.
+	reachable from the refs being pushed.  This can also be specified
+	with configuration variable 'push.followTags'.  For more
+	information, see 'push.followTags' in linkgit:git-config[1].
+
 
 --signed::
 	GPG-sign the push request to update refs on the receiving
diff --git a/builtin/push.c b/builtin/push.c
index fc771a9..47f0119 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -525,6 +525,11 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 
 	packet_trace_identity("push");
 	git_config(git_push_config, NULL);
+
+	/* set TRANSPORT_PUSH_FOLLOW_TAGS in flags so that --no-follow-tags may unset it */
+	if (push_follow_tags)
+		flags |= TRANSPORT_PUSH_FOLLOW_TAGS;
+
 	argc = parse_options(argc, argv, prefix, options, push_usage, 0);
 
 	if (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))
diff --git a/cache.h b/cache.h
index f704af5..9318189 100644
--- a/cache.h
+++ b/cache.h
@@ -648,6 +648,7 @@ enum push_default_type {
 extern enum branch_track git_branch_track;
 extern enum rebase_setup_type autorebase;
 extern enum push_default_type push_default;
+extern int push_follow_tags;
 
 enum object_creation_mode {
 	OBJECT_CREATION_USES_HARDLINKS = 0,
diff --git a/config.c b/config.c
index e5e64dc..cb237cd 100644
--- a/config.c
+++ b/config.c
@@ -977,6 +977,11 @@ static int git_default_push_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp(var, "push.followtags")) {
+		push_follow_tags = git_config_bool(var, value);
+		return 0;
+	}
+
 	/* Add other config variables here and to Documentation/config.txt. */
 	return 0;
 }
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c21190d..cffb2b8 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2188,6 +2188,7 @@ _git_config ()
 		pull.octopus
 		pull.twohead
 		push.default
+		push.followTags
 		rebase.autosquash
 		rebase.stat
 		receive.autogc
diff --git a/environment.c b/environment.c
index 1ade5c9..aef9587 100644
--- a/environment.c
+++ b/environment.c
@@ -52,6 +52,7 @@ unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
 enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
 enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
+int push_follow_tags = 0;
 #ifndef OBJECT_CREATION_MODE
 #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
 #endif
diff --git a/transport.c b/transport.c
index 0694a7c..ff5f63d 100644
--- a/transport.c
+++ b/transport.c
@@ -1148,7 +1148,7 @@ int transport_push(struct transport *transport,
 			match_flags |= MATCH_REFS_MIRROR;
 		if (flags & TRANSPORT_PUSH_PRUNE)
 			match_flags |= MATCH_REFS_PRUNE;
-		if (flags & TRANSPORT_PUSH_FOLLOW_TAGS)
+		if ((flags & TRANSPORT_PUSH_FOLLOW_TAGS))
 			match_flags |= MATCH_REFS_FOLLOW_TAGS;
 
 		if (match_push_refs(local_refs, &remote_refs,
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] push: allow --follow-tags to be set by config push.followTags
  2015-02-16  3:01 [PATCH] push: allow --follow-tags " Dave Olszewski
@ 2015-02-16  5:20 ` Jeff King
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2015-02-16  5:20 UTC (permalink / raw)
  To: Dave Olszewski; +Cc: git, gitster

On Sun, Feb 15, 2015 at 07:01:30PM -0800, Dave Olszewski wrote:

> +push.followTags::
> +	If set to true enable '--follow-tags' option by default.  You
> +	may override this configuration at time of push by specifying
> +	'--no-follow-tags'.

Thanks, this is something I've considered implementing myself, as I have
one repo that is frequently migrating tags from one remote to another,
and I often forget to specify the option.

> diff --git a/builtin/push.c b/builtin/push.c
> index fc771a9..47f0119 100644
> --- a/builtin/push.c
> +++ b/builtin/push.c
> @@ -525,6 +525,11 @@ int cmd_push(int argc, const char **argv, const char *prefix)
>  
>  	packet_trace_identity("push");
>  	git_config(git_push_config, NULL);
> +
> +	/* set TRANSPORT_PUSH_FOLLOW_TAGS in flags so that --no-follow-tags may unset it */
> +	if (push_follow_tags)
> +		flags |= TRANSPORT_PUSH_FOLLOW_TAGS;

You can see above that we use git_push_config to load our config...

> --- a/config.c
> +++ b/config.c
> @@ -977,6 +977,11 @@ static int git_default_push_config(const char *var, const char *value)
>  		return 0;
>  	}
>  
> +	if (!strcmp(var, "push.followtags")) {
> +		push_follow_tags = git_config_bool(var, value);
> +		return 0;
> +	}

But here you are adding to git_default_push_config, which is in another
file.

I'm trying to figure out why git_default_push_config exists at all. The
major difference from git_push_config is that the "default" variant will
get loaded for _all_ commands, not just "push". So if it affected
variables that were used by other commands, it would be needed. But all
it sets is push_default, which seems to be specific to builtin/push.c.

So I suspect it can be removed entirely, and folded into
git_config_push. But that's outside the scope of your patch.

What _is_ in the scope of your patch is that I think the new option you
are adding could go into git_push_config; it is definitely only about
the push command itself. And then you could declare it as:

  static int push_follow_tags;

without having to worry about making it an extern that is available
everywhere.

> diff --git a/transport.c b/transport.c
> index 0694a7c..ff5f63d 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -1148,7 +1148,7 @@ int transport_push(struct transport *transport,
>  			match_flags |= MATCH_REFS_MIRROR;
>  		if (flags & TRANSPORT_PUSH_PRUNE)
>  			match_flags |= MATCH_REFS_PRUNE;
> -		if (flags & TRANSPORT_PUSH_FOLLOW_TAGS)
> +		if ((flags & TRANSPORT_PUSH_FOLLOW_TAGS))
>  			match_flags |= MATCH_REFS_FOLLOW_TAGS;

This looks like just noise in the diff (I guess leftover from some
debugging you were doing). Is that correct?

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-16  5:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-15 23:39 [PATCH] push: allow --follow-tags' to be set by config push.followTags Dave Olszewski
2015-02-16  0:01 ` Junio C Hamano
2015-02-16  3:01   ` Dave Olszewski
  -- strict thread matches above, loose matches on Subject: below --
2015-02-16  3:01 [PATCH] push: allow --follow-tags " Dave Olszewski
2015-02-16  5:20 ` Jeff King

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 NNTP newsgroup(s).