{"thread":{"id":"23164","subject":"Feature request: option to not fetch tags for 'git remote' branches","startedAt":"2010-03-24T20:54:28Z","lastAt":"2010-03-30T08:09:28Z","messageCount":7,"participants":["Frans Pop","John Feuerstein","Björn Steinbrink","Samuel Tardieu"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"137743","messageId":"201003242154.29245.elendil@planet.nl","threadId":"23164","inReplyTo":null,"subject":"Feature request: option to not fetch tags for 'git remote' branches","fromName":"Frans Pop","fromEmail":"elendil@planet.nl","sentAt":"2010-03-24T20:54:28Z","receivedAt":"2010-03-24T20:54:28Z","isPatch":false,"sender":{"key":"elendil@planet.nl","avatar":null},"body":"I'm sometimes asked to build a kernel or rebase patches against a certain \ndevelopment repository. No problem, happy to do that.\n\nExcept that some of those repos have huge numbers of tags that I'm not \ninterested in and which only muddy the tags from the \"origin\" repo and my \nown.\n\nI mostly want to remove the remote again ASAP and having to semi-manually \nremove the unwanted tags afterwards is a nuisance.\n\nExample (on top of kernel mainline):\n$ git remote add -t master iwlwifi \\\n\tgit://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-2.6.git\nThis results in the addition of 326 'master-<date>' tags, 70 'merge-<date>' \ntags and 6 'snapshot-<date>' tags.\nSimilar effects for example from Ingo's \"tip\" repository.\n\nIt would be great to be able to tell 'git remote' to skip tags and only \nfetch the requested branch. A --no-tags option maybe?\n\nAFAIK this is currently not possible, although I'd happy to be proven \nwrong.\n\nCheers,\nFJP\n"},{"id":"137746","messageId":"4BAA7F5B.2040400@feurix.com","threadId":"23164","inReplyTo":"201003242154.29245.elendil@planet.nl","subject":"Re: Feature request: option to not fetch tags for 'git remote' branches","fromName":"John Feuerstein","fromEmail":"john@feurix.com","sentAt":"2010-03-24T21:08:43Z","receivedAt":"2010-03-24T21:08:43Z","isPatch":false,"sender":{"key":"john@feurix.com","avatar":null},"body":"Hello Frans,\n\n> It would be great to be able to tell 'git remote' to skip tags and only \n> fetch the requested branch. A --no-tags option maybe?\n> \n> AFAIK this is currently not possible, although I'd happy to be proven \n> wrong.\n\nhave a look at -n, --no-tags provided by git-fetch, ie.\n\n$ git remote add ... foo ...\n$ git fetch -n foo\n\n\nRegards,\nJohn\n"},{"id":"137748","messageId":"20100324213557.GA15639@atjola.homenet","threadId":"23164","inReplyTo":"4BAA7F5B.2040400@feurix.com","subject":"Re: Feature request: option to not fetch tags for 'git remote' branches","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2010-03-24T21:35:57Z","receivedAt":"2010-03-24T21:35:57Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2010.03.24 22:08:43 +0100, John Feuerstein wrote:\n> Hello Frans,\n> \n> > It would be great to be able to tell 'git remote' to skip tags and only \n> > fetch the requested branch. A --no-tags option maybe?\n> > \n> > AFAIK this is currently not possible, although I'd happy to be proven \n> > wrong.\n> \n> have a look at -n, --no-tags provided by git-fetch, ie.\n> \n> $ git remote add ... foo ...\n> $ git fetch -n foo\n\nAnd you can set remote.<name>.tagopt to --no-tags to make that the\ndefault.\n\nBjörn\n"},{"id":"137751","messageId":"201003242246.16286.elendil@planet.nl","threadId":"23164","inReplyTo":"4BAA7F5B.2040400@feurix.com","subject":"Re: Feature request: option to not fetch tags for 'git remote' branches","fromName":"Frans Pop","fromEmail":"elendil@planet.nl","sentAt":"2010-03-24T21:46:15Z","receivedAt":"2010-03-24T21:46:15Z","isPatch":false,"sender":{"key":"elendil@planet.nl","avatar":null},"body":"On Wednesday 24 March 2010, John Feuerstein wrote:\n> > It would be great to be able to tell 'git remote' to skip tags and\n> > only fetch the requested branch. A --no-tags option maybe?\n> >\n> > AFAIK this is currently not possible, although I'd happy to be proven\n> > wrong.\n>\n> have a look at -n, --no-tags provided by git-fetch, ie.\n>\n> $ git remote add ... foo ...\n> $ git fetch -n foo\n\nThanks John. I'll need to test if that's persistent, or that I'll have\nto remember to specify it with each fetch. I guess the option is also \nrecognized by 'git remote update'?\n\nAhh. I've just found 'remote.<name>.tagopt' in 'man git-config'.\nI still think it would be nice if that could be set with an option for\n'git remote add'. That would make life so much simpler :-)\n\nCheers,\nFJP\n"},{"id":"137960","messageId":"2010-03-27-20-10-25+trackit+sam@rfc1149.net","threadId":"23164","inReplyTo":"201003242246.16286.elendil@planet.nl","subject":"Re: Feature request: option to not fetch tags for 'git remote' branches","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2010-03-27T19:10:25Z","receivedAt":"2010-03-27T19:10:25Z","isPatch":false,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"Add a '--no-tags' option to 'git remote add' which adds a\n'remote.REMOTE.tagopt = --no-tags' to the configuration file.\n\n'git add -f -n REMOTE' will create a new remote and fetch from it\nwithout importing the tags. Subsequent 'git fetch REMOTE' will also\nnot import the tags.\n\nSigned-off-by: Samuel Tardieu <sam@rfc1149.net>\n---\n Documentation/git-remote.txt |    5 ++++-\n builtin/remote.c             |   11 ++++++++++-\n t/t5505-remote.sh            |   36 ++++++++++++++++++++++++++++++++++++\n 3 files changed, 50 insertions(+), 2 deletions(-)\n\n\n>>>>> \"Frans\" == Frans Pop <elendil@planet.nl> writes:\n\nFrans> I still think it would be nice if that could be set with an\nFrans> option for 'git remote add'. That would make life so much simpler\n\nThis should do the job.\n\n  Sam\n\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 3fc599c..9db3c35 100644\n--- a/Documentation/git-remote.txt\n+++ b/Documentation/git-remote.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git remote' [-v | --verbose]\n-'git remote add' [-t <branch>] [-m <master>] [-f] [--mirror] <name> <url>\n+'git remote add' [-t <branch>] [-m <master>] [-f] [-n] [--mirror] <name> <url>\n 'git remote rename' <old> <new>\n 'git remote rm' <name>\n 'git remote set-head' <name> (-a | -d | <branch>)\n@@ -51,6 +51,9 @@ update remote-tracking branches <name>/<branch>.\n With `-f` option, `git fetch <name>` is run immediately after\n the remote information is set up.\n +\n+With `-n` option, `git fetch <name>` does not import tags from\n+the remote repository.\n++\n With `-t <branch>` option, instead of the default glob\n refspec for the remote to track all branches under\n `$GIT_DIR/remotes/<name>/`, a refspec to track only `<branch>`\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 277765b..bb5606b 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -106,7 +106,7 @@ static int fetch_remote(const char *name)\n \n static int add(int argc, const char **argv)\n {\n-\tint fetch = 0, mirror = 0;\n+\tint fetch = 0, mirror = 0, notags = 0;\n \tstruct string_list track = { NULL, 0, 0 };\n \tconst char *master = NULL;\n \tstruct remote *remote;\n@@ -116,6 +116,8 @@ static int add(int argc, const char **argv)\n \n \tstruct option options[] = {\n \t\tOPT_BOOLEAN('f', \"fetch\", &fetch, \"fetch the remote branches\"),\n+\t\tOPT_BOOLEAN('n', \"no-tags\", &notags,\n+\t\t\t\"do not import remote tags when fetching\"),\n \t\tOPT_CALLBACK('t', \"track\", &track, \"branch\",\n \t\t\t\"branch(es) to track\", opt_parse_track),\n \t\tOPT_STRING('m', \"master\", &master, \"branch\", \"master branch\"),\n@@ -172,6 +174,13 @@ static int add(int argc, const char **argv)\n \t\t\treturn 1;\n \t}\n \n+\tif (notags) {\n+\t\tstrbuf_reset(&buf);\n+\t\tstrbuf_addf(&buf, \"remote.%s.tagopt\", name);\n+\t\tif (git_config_set(buf.buf, \"--no-tags\"))\n+\t\t\treturn 1;\n+\t}\n+\n \tif (fetch && fetch_remote(name))\n \t\treturn 1;\n \ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex 2692050..3a92a70 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -319,6 +319,42 @@ test_expect_success 'add alt && prune' '\n \t git rev-parse --verify refs/remotes/origin/side2)\n '\n \n+cat > test/expect << EOF\n+some-tag\n+EOF\n+\n+test_expect_success 'add with tags (default)' '\n+\t(cd one &&\n+\t git tag -a -m \"Some tag\" some-tag) &&\n+\t(mkdir add-tags &&\n+\t cd add-tags &&\n+\t git init &&\n+\t git remote add -f origin ../one &&\n+\t git tag -l some-tag > ../test/output &&\n+\t test_must_fail git config remote.origin.tagopt) &&\n+\t(cd one &&\n+\t git tag -d some-tag) &&\n+\ttest_cmp test/expect test/output\n+'\n+\n+cat > test/expect << EOF\n+--no-tags\n+EOF\n+\n+test_expect_success 'add --no-tags' '\n+\t(cd one &&\n+\t git tag -a -m \"Some tag\" some-tag) &&\n+\t(mkdir add-no-tags &&\n+\t cd add-no-tags &&\n+\t git init &&\n+\t git remote add -f -n origin ../one &&\n+\t git tag -l some-tag > ../test/output &&\n+\t git config remote.origin.tagopt >> ../test/output) &&\n+\t(cd one &&\n+\t git tag -d some-tag) &&\n+\ttest_cmp test/expect test/output\n+'\n+\n cat > one/expect << EOF\n   apis/master\n   apis/side\n"},{"id":"137962","messageId":"2010-03-27-20-25-15+trackit+sam@rfc1149.net","threadId":"23164","inReplyTo":"2010-03-27-20-10-25+trackit+sam@rfc1149.net","subject":"Re: Feature request: option to not fetch tags for 'git remote' branches","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2010-03-27T19:25:15Z","receivedAt":"2010-03-27T19:25:15Z","isPatch":false,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":">>>>> \"Sam\" == Samuel Tardieu <sam@rfc1149.net> writes:\n\nSam> Add a '--no-tags' option to 'git remote add' which adds a\nSam> 'remote.REMOTE.tagopt = --no-tags' to the configuration file.\n\nSam> 'git add -f -n REMOTE' will create a new remote and fetch from it\nSam> without importing the tags. Subsequent 'git fetch REMOTE' will also\nSam> not import the tags.\n\nSam> Signed-off-by: Samuel Tardieu <sam@rfc1149.net>\n\nI didn't notice that the subject was not appropriate. One can use:\n\nremote add: add a --no-tags (-n) option\n"},{"id":"138167","messageId":"201003301009.29412.elendil@planet.nl","threadId":"23164","inReplyTo":"2010-03-27-20-10-25+trackit+sam@rfc1149.net","subject":"Re: Feature request: option to not fetch tags for 'git remote' branches","fromName":"Frans Pop","fromEmail":"elendil@planet.nl","sentAt":"2010-03-30T08:09:28Z","receivedAt":"2010-03-30T08:09:28Z","isPatch":false,"sender":{"key":"elendil@planet.nl","avatar":null},"body":"On Saturday 27 March 2010, Samuel Tardieu wrote:\n> Add a '--no-tags' option to 'git remote add' which adds a\n> 'remote.REMOTE.tagopt = --no-tags' to the configuration file.\n>\n> 'git add -f -n REMOTE' will create a new remote and fetch from it\n> without importing the tags. Subsequent 'git fetch REMOTE' will also\n> not import the tags.\n\nNot tested, but looks as if it will do exactly what I had in mind. Thanks!\n"}]}