{"thread":{"id":"23530","subject":"[v3 PATCH 0/2] Add --tags/--no-tags options to \"git add remote\"","startedAt":"2010-04-19T23:31:19Z","lastAt":"2010-04-19T23:31:31Z","messageCount":3,"participants":["Samuel Tardieu"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"139941","messageId":"20100419233026.3631.67086.stgit@localhost.localdomain","threadId":"23530","inReplyTo":null,"subject":"[v3 PATCH 0/2] Add --tags/--no-tags options to \"git add remote\"","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2010-04-19T23:31:19Z","receivedAt":"2010-04-19T23:31:19Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"The following series adds the \"--[no-]tags\" option to \"git add remote\".\nSince \"-t\" was already taken for \"--track\", I only let the long\n\"--tags\" and \"--no-tags\" options.\n\nIn order to implement the \"--tags\" behaviour, I first had to add correct\nhandling of \"tagopt = --tags\" in remote configuration options.\n\n---\n\nSamuel Tardieu (2):\n      Honor \"tagopt = --tags\" configuration option\n      remote add: add a --no-tags (-n) option\n\n\n Documentation/git-remote.txt |    8 +++++\n builtin/remote.c             |   21 +++++++++++++-\n remote.c                     |    2 +\n t/t5505-remote.sh            |   63 ++++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 92 insertions(+), 2 deletions(-)\n"},{"id":"139942","messageId":"20100419233125.3631.97051.stgit@localhost.localdomain","threadId":"23530","inReplyTo":"20100419233026.3631.67086.stgit@localhost.localdomain","subject":"[v3 PATCH 1/2] Honor \"tagopt = --tags\" configuration option","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2010-04-19T23:31:25Z","receivedAt":"2010-04-19T23:31:25Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"If the \"tagopt = --tags\" option of a remote is set, all tags\nwill be fetched as in \"git fetch --tags\".\n\nSigned-off-by: Samuel Tardieu <sam@rfc1149.net>\n---\n Documentation/config.txt      |    4 +++-\n contrib/examples/git-fetch.sh |    4 +++-\n remote.c                      |    2 ++\n 3 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f45ae9c..8e7fd88 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1587,7 +1587,9 @@ remote.<name>.uploadpack::\n \n remote.<name>.tagopt::\n \tSetting this value to \\--no-tags disables automatic tag following when\n-\tfetching from remote <name>\n+\tfetching from remote <name>. Setting it to \\--tags will fetch every\n+\ttag from remote <name>, even if they are not reachable from remote\n+\tbranch heads.\n \n remote.<name>.vcs::\n \tSetting this to a value <vcs> will cause git to interact with\ndiff --git a/contrib/examples/git-fetch.sh b/contrib/examples/git-fetch.sh\nindex e44af2c..a314273 100755\n--- a/contrib/examples/git-fetch.sh\n+++ b/contrib/examples/git-fetch.sh\n@@ -127,10 +127,12 @@ then\n \torig_head=$(git rev-parse --verify HEAD 2>/dev/null)\n fi\n \n-# Allow --notags from remote.$1.tagopt\n+# Allow --tags/--notags from remote.$1.tagopt\n case \"$tags$no_tags\" in\n '')\n \tcase \"$(git config --get \"remote.$1.tagopt\")\" in\n+\t--tags)\n+\t\ttags=t ;;\n \t--no-tags)\n \t\tno_tags=t ;;\n \tesac\ndiff --git a/remote.c b/remote.c\nindex c70181c..0f073e0 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -443,6 +443,8 @@ static int handle_config(const char *key, const char *value, void *cb)\n \t} else if (!strcmp(subkey, \".tagopt\")) {\n \t\tif (!strcmp(value, \"--no-tags\"))\n \t\t\tremote->fetch_tags = -1;\n+\t\telse if (!strcmp(value, \"--tags\"))\n+\t\t\tremote->fetch_tags = 2;\n \t} else if (!strcmp(subkey, \".proxy\")) {\n \t\treturn git_config_string((const char **)&remote->http_proxy,\n \t\t\t\t\t key, value);\n"},{"id":"139943","messageId":"20100419233131.3631.20743.stgit@localhost.localdomain","threadId":"23530","inReplyTo":"20100419233026.3631.67086.stgit@localhost.localdomain","subject":"[v3 PATCH 2/2] remote add: add a --no-tags (-n) option","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2010-04-19T23:31:31Z","receivedAt":"2010-04-19T23:31:31Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"Add '--[no-]tags' options to 'git remote add' which add the\n'remote.REMOTE.tagopt = --[no-]tags' to the configuration file.\nThis mimics the \"--tags\" and \"--no-tags\" options of \"git fetch\".\n\nSigned-off-by: Samuel Tardieu <sam@rfc1149.net>\n---\n Documentation/git-remote.txt |    8 +++++\n builtin/remote.c             |   21 +++++++++++++-\n t/t5505-remote.sh            |   63 ++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 90 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt\nindex 3fc599c..ebaaadc 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] [--tags|--no-tags] [--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,12 @@ 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 `--tags` option, `git fetch <name>` imports every tag from the\n+remote repository.\n++\n+With `--no-tags` 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..0e99a99 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -104,9 +104,15 @@ static int fetch_remote(const char *name)\n \treturn 0;\n }\n \n+enum {\n+\tTAGS_UNSET = 0,\n+\tTAGS_DEFAULT = 1,\n+\tTAGS_SET = 2\n+};\n+\n static int add(int argc, const char **argv)\n {\n-\tint fetch = 0, mirror = 0;\n+\tint fetch = 0, mirror = 0, fetch_tags = TAGS_DEFAULT;\n \tstruct string_list track = { NULL, 0, 0 };\n \tconst char *master = NULL;\n \tstruct remote *remote;\n@@ -116,6 +122,11 @@ 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_SET_INT(0, \"tags\", &fetch_tags,\n+\t\t\t    \"import all tags and associated objects when fetching\",\n+\t\t\t    TAGS_SET),\n+\t\tOPT_SET_INT(0, NULL, &fetch_tags,\n+\t\t\t    \"or do not fetch any tag at all (--no-tags)\", TAGS_UNSET),\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 +183,14 @@ static int add(int argc, const char **argv)\n \t\t\treturn 1;\n \t}\n \n+\tif (fetch_tags != TAGS_DEFAULT) {\n+\t\tstrbuf_reset(&buf);\n+\t\tstrbuf_addf(&buf, \"remote.%s.tagopt\", name);\n+\t\tif (git_config_set(buf.buf,\n+\t\t\tfetch_tags == TAGS_SET ? \"--tags\" : \"--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..79fe9a0 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -320,6 +320,69 @@ 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 reachable tags (default)' '\n+\t(cd one &&\n+\t touch foobar &&\n+\t git add foobar &&\n+\t git commit -m \"Foobar\" &&\n+\t git tag -a -m \"Foobar tag\" foobar-tag &&\n+\t git reset --hard HEAD~1 &&\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 git tag -l foobar-tag >> ../test/output &&\n+\t test_must_fail git config remote.origin.tagopt) &&\n+\ttest_cmp test/expect test/output\n+'\n+\n+cat > test/expect << EOF\n+some-tag\n+foobar-tag\n+--tags\n+EOF\n+\n+test_expect_success 'add --tags' '\n+\t(rm -rf add-tags &&\n+\t mkdir add-tags &&\n+\t cd add-tags &&\n+\t git init &&\n+\t git remote add -f --tags origin ../one &&\n+\t git tag -l some-tag > ../test/output &&\n+\t git tag -l foobar-tag >> ../test/output &&\n+\t git config remote.origin.tagopt >> ../test/output) &&\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(rm -rf add-tags &&\n+\t mkdir add-no-tags &&\n+\t cd add-no-tags &&\n+\t git init &&\n+\t git remote add -f --no-tags origin ../one &&\n+\t git tag -l some-tag > ../test/output &&\n+\t git tag -l foobar-tag > ../test/output &&\n+\t git config remote.origin.tagopt >> ../test/output) &&\n+\t(cd one &&\n+\t git tag -d some-tag foobar-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"}]}