[PATCH/RFC] fetch: allow command line --tags to override config

Subsystems: the rest

5 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH/RFC] fetch: allow command line --tags to override config

From: Daniel Johnson <hidden>
Date: 2016-06-15 22:49:14

Originally, if remote.<name>.tagopt was set, the --tags and option would
have no effect when given to git fetch. So if
tagopt="--no-tags"

	git fetch --tags

would not actually fetch tags.

This patch changes this behavior to only follow what is written in the
config if there is no option passed by the command line.

Signed-off-by: Daniel Johnson <redacted>
---
 builtin/fetch.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 1b67f5f..7a53144 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -675,10 +675,12 @@ static int do_fetch(struct transport *transport,
 
 	for_each_ref(add_existing, &existing_refs);
 
-	if (transport->remote->fetch_tags == 2 && tags != TAGS_UNSET)
-		tags = TAGS_SET;
-	if (transport->remote->fetch_tags == -1)
-		tags = TAGS_UNSET;
+	if (tags == TAGS_DEFAULT) {
+		if (transport->remote->fetch_tags == 2)
+			tags = TAGS_SET;
+		if (transport->remote->fetch_tags == -1)
+			tags = TAGS_UNSET;
+	}
 
 	if (!transport->get_refs_list || !transport->fetch)
 		die("Don't know how to fetch from %s", transport->url);
-- 
1.7.2

Re: [PATCH/RFC] fetch: allow command line --tags to override config

From: Tay Ray Chuan <hidden>
Date: 2016-06-15 22:49:15

Hi,

On Thu, Aug 5, 2010 at 2:56 AM, Daniel Johnson [off-list ref] wrote:
Originally, if remote.<name>.tagopt was set, the --tags and option would
have no effect when given to git fetch. So if
tagopt="--no-tags"

       git fetch --tags

would not actually fetch tags.

This patch changes this behavior to only follow what is written in the
config if there is no option passed by the command line.

Signed-off-by: Daniel Johnson <redacted>
This is pretty confusing as it is. Could you please provide a patch
for the git-fetch documentation too?

-- 
Cheers,
Ray Chuan

[PATCH] Documentation: changes in the behavior of tagopt

From: Daniel Johnson <hidden>
Date: 2016-06-15 22:49:15

---
How does this look?

 Documentation/config.txt        |    4 +++-
 Documentation/fetch-options.txt |    8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index f81fb91..682ebef 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1627,7 +1627,9 @@ remote.<name>.tagopt::
 	Setting this value to \--no-tags disables automatic tag following when
 	fetching from remote <name>. Setting it to \--tags will fetch every
 	tag from remote <name>, even if they are not reachable from remote
-	branch heads.
+	branch heads. Passing these flags directly to linkgit:git-fetch[1] can
+	override this setting. See options \--tags and \--no-tags of
+	linkgit:git-fetch[1].
 
 remote.<name>.vcs::
 	Setting this to a value <vcs> will cause git to interact with
diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt
index 9333c42..2fdfeac 100644
--- a/Documentation/fetch-options.txt
+++ b/Documentation/fetch-options.txt
@@ -49,7 +49,9 @@ ifndef::git-pull[]
 endif::git-pull[]
 	By default, tags that point at objects that are downloaded
 	from the remote repository are fetched and stored locally.
-	This option disables this automatic tag following.
+	This option disables this automatic tag following. The default
+	behavior for a remote may be specified with the remote.<name>.tagopt
+	setting. See linkgit:git-clone[1].
 
 -t::
 --tags::
@@ -58,7 +60,9 @@ endif::git-pull[]
 	objects reachable from the branch heads that are being
 	tracked will not be fetched by this mechanism.  This
 	flag lets all tags and their associated objects be
-	downloaded.
+	downloaded. The default behavior for a remote may be
+	specified with the remote.<name>.tagopt setting. See
+	linkgit:git-clone[1].
 
 -u::
 --update-head-ok::
-- 
1.7.2

Re: [PATCH] Documentation: changes in the behavior of tagopt

From: Tay Ray Chuan <hidden>
Date: 2016-06-15 22:49:16

On Fri, Aug 6, 2010 at 9:54 PM, Daniel Johnson [off-list ref] wrote:
---
How does this look?
Looks ok - now you'll have to squash this with your code patch.

-- 
Cheers,
Ray Chuan

[RFC/PATCHv2] fetch: allow command line --tags to override config

From: Daniel Johnson <hidden>
Date: 2016-06-15 22:49:18

Originally, if remote.<name>.tagopt was set, the --tags and option would
have no effect when given to git fetch. So if
tagopt="--no-tags"

	git fetch --tags

would not actually fetch tags.

This patch changes this behavior to only follow what is written in the
config if there is no option passed by the command line.

Signed-off-by: Daniel Johnson <redacted>
---
On Sat, Aug 7, 2010 at 10:17 PM, Tay Ray Chuan [off-list ref] wrote:
On Fri, Aug 6, 2010 at 9:54 PM, Daniel Johnson [off-list ref] wrote:
quoted
---
How does this look?
Looks ok - now you'll have to squash this with your code patch.
And here it is. Sorry about the lateness. I also fixed a mistake I made in the
documentation (linked to the wrong secton).

I'd still like comments on both the code and the change in behavior behind it.

 Documentation/config.txt        |    4 +++-
 Documentation/fetch-options.txt |    8 ++++++--
 builtin/fetch.c                 |   10 ++++++----
 3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index f81fb91..682ebef 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1627,7 +1627,9 @@ remote.<name>.tagopt::
 	Setting this value to \--no-tags disables automatic tag following when
 	fetching from remote <name>. Setting it to \--tags will fetch every
 	tag from remote <name>, even if they are not reachable from remote
-	branch heads.
+	branch heads. Passing these flags directly to linkgit:git-fetch[1] can
+	override this setting. See options \--tags and \--no-tags of
+	linkgit:git-fetch[1].
 
 remote.<name>.vcs::
 	Setting this to a value <vcs> will cause git to interact with
diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt
index 9333c42..470ac31 100644
--- a/Documentation/fetch-options.txt
+++ b/Documentation/fetch-options.txt
@@ -49,7 +49,9 @@ ifndef::git-pull[]
 endif::git-pull[]
 	By default, tags that point at objects that are downloaded
 	from the remote repository are fetched and stored locally.
-	This option disables this automatic tag following.
+	This option disables this automatic tag following. The default
+	behavior for a remote may be specified with the remote.<name>.tagopt
+	setting. See linkgit:git-config[1].
 
 -t::
 --tags::
@@ -58,7 +60,9 @@ endif::git-pull[]
 	objects reachable from the branch heads that are being
 	tracked will not be fetched by this mechanism.  This
 	flag lets all tags and their associated objects be
-	downloaded.
+	downloaded. The default behavior for a remote may be
+	specified with the remote.<name>.tagopt setting. See
+	linkgit:git-config[1].
 
 -u::
 --update-head-ok::
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 1b67f5f..7a53144 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -675,10 +675,12 @@ static int do_fetch(struct transport *transport,
 
 	for_each_ref(add_existing, &existing_refs);
 
-	if (transport->remote->fetch_tags == 2 && tags != TAGS_UNSET)
-		tags = TAGS_SET;
-	if (transport->remote->fetch_tags == -1)
-		tags = TAGS_UNSET;
+	if (tags == TAGS_DEFAULT) {
+		if (transport->remote->fetch_tags == 2)
+			tags = TAGS_SET;
+		if (transport->remote->fetch_tags == -1)
+			tags = TAGS_UNSET;
+	}
 
 	if (!transport->get_refs_list || !transport->fetch)
 		die("Don't know how to fetch from %s", transport->url);
-- 
1.7.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help