{"thread":{"id":"23526","subject":"[PATCH] remote add: add a --no-tags (-n) option","startedAt":"2010-04-19T13:50:14Z","lastAt":"2010-04-19T23:34:38Z","messageCount":7,"participants":["Samuel Tardieu","Michael J Gruber","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"139897","messageId":"20100419135014.1077.28627.stgit@localhost.localdomain","threadId":"23526","inReplyTo":null,"subject":"[PATCH] remote add: add a --no-tags (-n) option","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2010-04-19T13:50:14Z","receivedAt":"2010-04-19T13:50:14Z","isPatch":true,"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\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 230c0cd..d4ed7ea 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -320,6 +320,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":"139909","messageId":"4BCC8073.80109@drmicha.warpmail.net","threadId":"23526","inReplyTo":"20100419135014.1077.28627.stgit@localhost.localdomain","subject":"Re: [PATCH] remote add: add a --no-tags (-n) option","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-04-19T16:10:27Z","receivedAt":"2010-04-19T16:10:27Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Samuel Tardieu venit, vidit, dixit 19.04.2010 15:50:\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\nI guess you mean 'git remote add' here.\n\nThe general directions for this is nice. Just don't expect much response\nnow in rc-phase.\n\n> without importing the tags. Subsequent 'git fetch REMOTE' will also\n> not import the tags.\n> \n> Signed-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> diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\n> index 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>`\n> diff --git a/builtin/remote.c b/builtin/remote.c\n> index 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\nIs this buf freed again?\n\n> +\t}\n> +\n>  \tif (fetch && fetch_remote(name))\n>  \t\treturn 1;\n>  \n> diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\n> index 230c0cd..d4ed7ea 100755\n> --- a/t/t5505-remote.sh\n> +++ b/t/t5505-remote.sh\n> @@ -320,6 +320,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> \n"},{"id":"139910","messageId":"2010-04-19-18-19-15+trackit+sam@rfc1149.net","threadId":"23526","inReplyTo":"4BCC8073.80109@drmicha.warpmail.net","subject":"Re: [PATCH] remote add: add a --no-tags (-n) option","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2010-04-19T16:19:15Z","receivedAt":"2010-04-19T16:19:15Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":">>>>> \"Michael\" == Michael J Gruber <git@drmicha.warpmail.net> writes:\n\nMichael> Samuel Tardieu venit, vidit, dixit 19.04.2010 15:50:\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\nMichael> I guess you mean 'git remote add' here.\n\nYes, indeed.\n\nMichael> Is this buf freed again?\n\nAbsolutely, there is a \"strbuf_release(&buf)\" a few lines down (the\nbuffer may be reused in the meantime).\n\n  Sam\n-- \nSamuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/\n"},{"id":"139922","messageId":"7vvdbnqpis.fsf@alter.siamese.dyndns.org","threadId":"23526","inReplyTo":"20100419135014.1077.28627.stgit@localhost.localdomain","subject":"Re: [PATCH] remote add: add a --no-tags (-n) option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-19T18:13:31Z","receivedAt":"2010-04-19T18:13:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Samuel Tardieu <sam@rfc1149.net> writes:\n\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\nAny long-opt that begins with \"no-\" looks wrong, especially that will\nallow people to say \"--no-no-tags\".  Perhaps something like this is\nnecessary.\n\n    { OPTION_BOOLEAN, 0, \"tags\", &tags, NULL, \"fetch tags\", PARSE_OPT_NOARG }\n\nOr imitate whatever we do in builtin-fetch.c; although I suspect the\ndefault would be different in this command and \"git fetch\", so you may\nneed to adjust for the difference a bit.\n"},{"id":"139924","messageId":"2010-04-19-22-19-11+trackit+sam@rfc1149.net","threadId":"23526","inReplyTo":"7vvdbnqpis.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] remote add: add a --no-tags (-n) option","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2010-04-19T20:19:10Z","receivedAt":"2010-04-19T20:19:10Z","isPatch":true,"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 remote add -f -n REMOTE' will create a new remote and fetch\nfrom it without importing the tags. Subsequent 'git fetch REMOTE'\nwill also not import the tags.\n\nSigned-off-by: Samuel Tardieu <sam@rfc1149.net>\n\n---\n Documentation/git-remote.txt |    5 ++++-\n builtin/remote.c             |   12 +++++++++++-\n t/t5505-remote.sh            |   41 +++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 56 insertions(+), 2 deletions(-)\n\n>>>>> \"Junio\" == Junio C Hamano <gitster@pobox.com> writes:\n\nJunio> Any long-opt that begins with \"no-\" looks wrong, especially that\nJunio> will allow people to say \"--no-no-tags\".  Perhaps something like\nJunio> this is necessary.\n\nJunio>     { OPTION_BOOLEAN, 0, \"tags\", &tags, NULL, \"fetch tags\",\nJunio> PARSE_OPT_NOARG }\n\nIn this version I've used \"PARSE_OPT_NOARG | PARSE_OPT_NONEG\" to forbid\n\"--no-no-tags\" and added a test for it.\n\nJunio> Or imitate whatever we do in builtin-fetch.c; although I suspect\nJunio> the default would be different in this command and \"git fetch\",\nJunio> so you may need to adjust for the difference a bit.\n\nI don't think we need to add \"--tags\" to \"git remote add\", do you? If\nyou do, this is not difficult to add using the \"git fetch\" logic you\ndescribe.\n\n  Sam\n-- \nSamuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/\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..ff16487 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,9 @@ 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\t{ OPTION_BOOLEAN, 'n', \"no-tags\", &notags, NULL,\n+\t\t  \"do not import remote tags when fetching\",\n+\t\t  PARSE_OPT_NOARG | PARSE_OPT_NONEG },\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 +175,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 230c0cd..47e9e67 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -320,6 +320,47 @@ 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+test_expect_success 'reject --no-no-tags' '\n+\t(cd add-no-tags &&\n+\t test_must_fail git remote add -f --no-no-tags neworigin ../one)\n+'\n+\n cat > one/expect << EOF\n   apis/master\n   apis/side\n-- \ntg: (af02b6d..) t/no-tags (depends on: origin/next)\n"},{"id":"139933","messageId":"7vr5mbp0tt.fsf@alter.siamese.dyndns.org","threadId":"23526","inReplyTo":"2010-04-19-22-19-11+trackit+sam@rfc1149.net","subject":"Re: [PATCH] remote add: add a --no-tags (-n) option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-19T21:52:14Z","receivedAt":"2010-04-19T21:52:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Samuel Tardieu <sam@rfc1149.net> writes:\n\n> I don't think we need to add \"--tags\" to \"git remote add\", do you? If\n> you do, this is not difficult to add using the \"git fetch\" logic you\n> describe.\n\nI actually do suspect that would make the interface more consistent.\n"},{"id":"139944","messageId":"2010-04-20-01-34-38+trackit+sam@rfc1149.net","threadId":"23526","inReplyTo":"7vr5mbp0tt.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] remote add: add a --no-tags (-n) option","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2010-04-19T23:34:38Z","receivedAt":"2010-04-19T23:34:38Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":">>>>> \"Junio\" == Junio C Hamano <gitster@pobox.com> writes:\n\nJunio> Samuel Tardieu <sam@rfc1149.net> writes:\n>> I don't think we need to add \"--tags\" to \"git remote add\", do you? If\n>> you do, this is not difficult to add using the \"git fetch\" logic you\n>> describe.\n\nJunio> I actually do suspect that would make the interface more\nJunio> consistent.\n\nOk, sent as a v3 serie.\n\n  Sam\n-- \nSamuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/\n"}]}