{"thread":{"id":"23228","subject":"[PATCH] remote add: add a --no-tags (-n) option","startedAt":"2010-03-29T12:07:48Z","lastAt":"2010-03-29T12:07:48Z","messageCount":1,"participants":["Samuel Tardieu"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"138076","messageId":"20100329120748.4458.66495.stgit@localhost.localdomain","threadId":"23228","inReplyTo":null,"subject":"[PATCH] remote add: add a --no-tags (-n) option","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2010-03-29T12:07:48Z","receivedAt":"2010-03-29T12:07:48Z","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"}]}