{"thread":{"id":"45811","subject":"[PATCH v3 0/5] clone: --no-tags option","startedAt":"2017-04-26T23:12:56Z","lastAt":"2017-05-01T01:41:55Z","messageCount":23,"participants":["Ævar Arnfjörð Bjarmason","Junio C Hamano","Brandon Williams","Stefan Beller"],"isPatch":true,"patchVersion":3,"patchTotal":5},"messages":[{"id":"318008","messageId":"20170426231236.27219-1-avarab@gmail.com","threadId":"45811","inReplyTo":null,"subject":"[PATCH v3 0/5] clone: --no-tags option","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-04-26T23:12:31Z","receivedAt":"2017-04-26T23:12:56Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This is an expansion of the previously solo 02/05 \"clone: add a\n--no-tags option to clone without tags\" patch (see\n<20170418191553.15464-1-avarab@gmail.com>).\n\nThis addresses the comments by Junio & Jonathan Nieder on v2 (thanks a\nlot), and in addition implements a --no-tags-submodules option. That\ncode was implemented by Brandon & sent to me privately after I'd\nfailed to come up with it, but I added tests, a commit message & bash\ncompletion to it.\n\nThe WIP 5/5 patch implements a submodule.NAME.tags config facility for\nthe option, but is broken currently & floats along in this submission\nas an RFC patch. AFAICT it *should* work and it goes through all the\nmotions the similar existing *.shallow config does, but for some\nreason the tags=false option isn't picked up & propagated in a freshly\ncloned submodule.\n\nI'm probably missing something trivial, but I can't see what it is,\nI'm hoping thath either Stefan or Brandon will see what that is.\n\nBrandon Williams (1):\n  clone: add a --no-tags-submodules to pass --no-tags to submodules\n\nÆvar Arnfjörð Bjarmason (4):\n  tests: change \"cd ... && git fetch\" to \"cd &&\\n\\tgit fetch\"\n  clone: add a --no-tags option to clone without tags\n  tests: rename a test having to do with shallow submodules\n  WIP clone: add a --[no-]recommend-tags & submodule.NAME.tags config\n\n Documentation/git-clone.txt                        |  21 ++++\n Documentation/git-submodule.txt                    |   8 +-\n builtin/clone.c                                    |  19 +++-\n builtin/submodule--helper.c                        |  21 +++-\n contrib/completion/git-completion.bash             |   3 +\n git-submodule.sh                                   |  13 ++-\n submodule-config.c                                 |   8 ++\n submodule-config.h                                 |   1 +\n t/t5612-clone-refspec.sh                           | 103 +++++++++++++++++---\n ...odules.sh => t5614-clone-submodules-shallow.sh} |   0\n t/t5616-clone-submodules-tags.sh                   | 106 +++++++++++++++++++++\n 11 files changed, 284 insertions(+), 19 deletions(-)\n rename t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} (100%)\n create mode 100755 t/t5616-clone-submodules-tags.sh\n\n-- \n2.11.0\n\n"},{"id":"318009","messageId":"20170426231236.27219-2-avarab@gmail.com","threadId":"45811","inReplyTo":"20170426231236.27219-1-avarab@gmail.com","subject":"[PATCH v3 1/5] tests: change \"cd ... && git fetch\" to \"cd &&\\n\\tgit fetch\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-04-26T23:12:32Z","receivedAt":"2017-04-26T23:13:05Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change occurrences \"cd\" followed by \"fetch\" on a single line to be on\ntwo lines.\n\nThis is purely a stylistic change pointed out in code review for an\nunrelated patch. Change the these tests use so new tests added later\nusing the more common style don't look out of place.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t5612-clone-refspec.sh | 27 ++++++++++++++++++---------\n 1 file changed, 18 insertions(+), 9 deletions(-)\n\ndiff --git a/t/t5612-clone-refspec.sh b/t/t5612-clone-refspec.sh\nindex 7ace2535c8..97c847fab6 100755\n--- a/t/t5612-clone-refspec.sh\n+++ b/t/t5612-clone-refspec.sh\n@@ -59,7 +59,8 @@ test_expect_success 'setup' '\n \n test_expect_success 'by default all branches will be kept updated' '\n \t(\n-\t\tcd dir_all && git fetch &&\n+\t\tcd dir_all &&\n+\t\tgit fetch &&\n \t\tgit for-each-ref refs/remotes/origin |\n \t\tsed -e \"/HEAD$/d\" \\\n \t\t    -e \"s|/remotes/origin/|/heads/|\" >../actual\n@@ -71,7 +72,8 @@ test_expect_success 'by default all branches will be kept updated' '\n \n test_expect_success 'by default no tags will be kept updated' '\n \t(\n-\t\tcd dir_all && git fetch &&\n+\t\tcd dir_all &&\n+\t\tgit fetch &&\n \t\tgit for-each-ref refs/tags >../actual\n \t) &&\n \tgit for-each-ref refs/tags >expect &&\n@@ -80,7 +82,8 @@ test_expect_success 'by default no tags will be kept updated' '\n \n test_expect_success '--single-branch while HEAD pointing at master' '\n \t(\n-\t\tcd dir_master && git fetch &&\n+\t\tcd dir_master &&\n+\t\tgit fetch &&\n \t\tgit for-each-ref refs/remotes/origin |\n \t\tsed -e \"/HEAD$/d\" \\\n \t\t    -e \"s|/remotes/origin/|/heads/|\" >../actual\n@@ -92,7 +95,8 @@ test_expect_success '--single-branch while HEAD pointing at master' '\n \n test_expect_success '--single-branch while HEAD pointing at side' '\n \t(\n-\t\tcd dir_side && git fetch &&\n+\t\tcd dir_side &&\n+\t\tgit fetch &&\n \t\tgit for-each-ref refs/remotes/origin |\n \t\tsed -e \"/HEAD$/d\" \\\n \t\t    -e \"s|/remotes/origin/|/heads/|\" >../actual\n@@ -104,7 +108,8 @@ test_expect_success '--single-branch while HEAD pointing at side' '\n \n test_expect_success '--single-branch with explicit --branch side' '\n \t(\n-\t\tcd dir_side2 && git fetch &&\n+\t\tcd dir_side2 &&\n+\t\tgit fetch &&\n \t\tgit for-each-ref refs/remotes/origin |\n \t\tsed -e \"/HEAD$/d\" \\\n \t\t    -e \"s|/remotes/origin/|/heads/|\" >../actual\n@@ -116,7 +121,8 @@ test_expect_success '--single-branch with explicit --branch side' '\n \n test_expect_success '--single-branch with explicit --branch with tag fetches updated tag' '\n \t(\n-\t\tcd dir_tag && git fetch &&\n+\t\tcd dir_tag &&\n+\t\tgit fetch &&\n \t\tgit for-each-ref refs/tags >../actual\n \t) &&\n \tgit for-each-ref refs/tags >expect &&\n@@ -125,7 +131,8 @@ test_expect_success '--single-branch with explicit --branch with tag fetches upd\n \n test_expect_success '--single-branch with --mirror' '\n \t(\n-\t\tcd dir_mirror && git fetch &&\n+\t\tcd dir_mirror &&\n+\t\tgit fetch &&\n \t\tgit for-each-ref refs > ../actual\n \t) &&\n \tgit for-each-ref refs >expect &&\n@@ -134,7 +141,8 @@ test_expect_success '--single-branch with --mirror' '\n \n test_expect_success '--single-branch with explicit --branch and --mirror' '\n \t(\n-\t\tcd dir_mirror_side && git fetch &&\n+\t\tcd dir_mirror_side &&\n+\t\tgit fetch &&\n \t\tgit for-each-ref refs > ../actual\n \t) &&\n \tgit for-each-ref refs >expect &&\n@@ -143,7 +151,8 @@ test_expect_success '--single-branch with explicit --branch and --mirror' '\n \n test_expect_success '--single-branch with detached' '\n \t(\n-\t\tcd dir_detached && git fetch &&\n+\t\tcd dir_detached &&\n+\t\tgit fetch &&\n \t\tgit for-each-ref refs/remotes/origin |\n \t\tsed -e \"/HEAD$/d\" \\\n \t\t    -e \"s|/remotes/origin/|/heads/|\" >../actual\n-- \n2.11.0\n\n"},{"id":"318010","messageId":"20170426231236.27219-3-avarab@gmail.com","threadId":"45811","inReplyTo":"20170426231236.27219-1-avarab@gmail.com","subject":"[PATCH v3 2/5] clone: add a --no-tags option to clone without tags","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-04-26T23:12:33Z","receivedAt":"2017-04-26T23:13:08Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a --no-tags option to clone without fetching any tags.\n\nWithout this change there's no easy way to clone a repository without\nalso fetching its tags.\n\nWhen supplying --single-branch the primary remote branch will be\ncloned, but in addition tags will be followed & retrieved. Now\n--no-tags can be added --single-branch to clone a repository without\ntags, and which only tracks a single upstream branch.\n\nThis option works without --single-branch as well, and will do a\nnormal clone but not fetch any tags.\n\nMany git commands pay some fixed overhead as a function of the number\nof references. E.g. creating ~40k tags in linux.git will cause a\ncommand like `git log -1 >/dev/null` to run in over a second instead\nof in a matter of milliseconds, in addition numerous other things will\nslow down, e.g. \"git log <TAB>\" with the bash completion will slowly\nshow ~40k references instead of 1.\n\nThe user might want to avoid all of that overhead to simply use a\nrepository like that to browse the \"master\" branch, or something like\na CI tool might want to keep that one branch up-to-date without caring\nabout any other references.\n\nWithout this change the only way of accomplishing this was either by\nmanually tweaking the config in a fresh repository:\n\n    git init git &&\n    cat >git/.git/config <<EOF &&\n    [remote \"origin\"]\n        url = git@github.com:git/git.git\n        tagOpt = --no-tags\n        fetch = +refs/heads/master:refs/remotes/origin/master\n    [branch \"master\"]\n        remote = origin\n        merge = refs/heads/master\n    EOF\n    cd git &&\n    git pull\n\nWhich requires hardcoding the \"master\" name, which may not be the main\n--single-branch would have retrieved, or alternatively by setting\ntagOpt=--no-tags right after cloning & deleting any existing tags:\n\n    git clone --single-branch git@github.com:git/git.git &&\n    cd git &&\n    git config remote.origin.tagOpt --no-tags &&\n    git tag -l | xargs git tag -d\n\nWhich of course was also subtly buggy if --branch was pointed at a\ntag, leaving the user in a detached head:\n\n    git clone --single-branch --branch v2.12.0 git@github.com:git/git.git &&\n    cd git &&\n    git config remote.origin.tagOpt --no-tags &&\n    git tag -l | xargs git tag -d\n\nNow all this complexity becomes the much simpler:\n\n    git clone --single-branch --no-tags git@github.com:git/git.git\n\nOr in the case of cloning a single tag \"branch\":\n\n    git clone --single-branch --branch v2.12.0 --no-tags git@github.com:git/git.git\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-clone.txt            | 14 ++++++-\n builtin/clone.c                        | 13 +++++-\n contrib/completion/git-completion.bash |  1 +\n t/t5612-clone-refspec.sh               | 76 +++++++++++++++++++++++++++++++++-\n 4 files changed, 99 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex 30052cce49..83c8e9b394 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -13,7 +13,7 @@ SYNOPSIS\n \t  [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]\n \t  [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]\n \t  [--dissociate] [--separate-git-dir <git dir>]\n-\t  [--depth <depth>] [--[no-]single-branch]\n+\t  [--depth <depth>] [--[no-]single-branch] [--no-tags]\n \t  [--recurse-submodules] [--[no-]shallow-submodules]\n \t  [--jobs <n>] [--] <repository> [<directory>]\n \n@@ -215,6 +215,18 @@ objects from the source repository into a pack in the cloned repository.\n \tbranch when `--single-branch` clone was made, no remote-tracking\n \tbranch is created.\n \n+--no-tags::\n+\tDon't clone any tags, and set\n+\t`remote.<remote>.tagOpt=--no-tags` in the config, ensuring\n+\tthat future `git pull` and `git fetch` operations won't follow\n+\tany tags. Subsequent explicit tag fetches will still work,\n+\t(see linkgit:git-fetch[1]).\n++\n+Can be used in conjunction with `--single-branch` to clone and\n+maintain a branch with no references other than a single cloned\n+branch. This is useful e.g. to maintain minimal clones of the default\n+branch of some repository for search indexing.\n+\n --recurse-submodules[=<pathspec]::\n \tAfter the clone is created, initialize and clone submodules\n \twithin based on the provided pathspec.  If no pathspec is\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex de85b85254..05f52d6f2b 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -40,6 +40,7 @@ static const char * const builtin_clone_usage[] = {\n \n static int option_no_checkout, option_bare, option_mirror, option_single_branch = -1;\n static int option_local = -1, option_no_hardlinks, option_shared;\n+static int option_no_tags;\n static int option_shallow_submodules;\n static int deepen;\n static char *option_template, *option_depth, *option_since;\n@@ -120,6 +121,8 @@ static struct option builtin_clone_options[] = {\n \t\t\tN_(\"deepen history of shallow clone, excluding rev\")),\n \tOPT_BOOL(0, \"single-branch\", &option_single_branch,\n \t\t    N_(\"clone only one branch, HEAD or --branch\")),\n+\tOPT_BOOL(0, \"no-tags\", &option_no_tags,\n+\t\t N_(\"don't clone any tags, and make later fetches not to follow them\")),\n \tOPT_BOOL(0, \"shallow-submodules\", &option_shallow_submodules,\n \t\t    N_(\"any cloned submodules will be shallow\")),\n \tOPT_STRING(0, \"separate-git-dir\", &real_git_dir, N_(\"gitdir\"),\n@@ -563,7 +566,7 @@ static struct ref *wanted_peer_refs(const struct ref *refs,\n \t} else\n \t\tget_fetch_map(refs, refspec, &tail, 0);\n \n-\tif (!option_mirror && !option_single_branch)\n+\tif (!option_mirror && !option_single_branch && !option_no_tags)\n \t\tget_fetch_map(refs, tag_refspec, &tail, 0);\n \n \treturn local_refs;\n@@ -652,7 +655,7 @@ static void update_remote_refs(const struct ref *refs,\n \n \tif (refs) {\n \t\twrite_remote_refs(mapped_refs);\n-\t\tif (option_single_branch)\n+\t\tif (option_single_branch && !option_no_tags)\n \t\t\twrite_followtags(refs, msg);\n \t}\n \n@@ -1035,6 +1038,12 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tgit_config_set(key.buf, repo);\n \tstrbuf_reset(&key);\n \n+\tif (option_no_tags) {\n+\t\tstrbuf_addf(&key, \"remote.%s.tagOpt\", option_origin);\n+\t\tgit_config_set(key.buf, \"--no-tags\");\n+\t\tstrbuf_reset(&key);\n+\t}\n+\n \tif (option_required_reference.nr || option_optional_reference.nr)\n \t\tsetup_reference();\n \ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 1150164d5c..6da997cf42 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1309,6 +1309,7 @@ _git_clone ()\n \t\t\t--template=\n \t\t\t--depth\n \t\t\t--single-branch\n+\t\t\t--no-tags\n \t\t\t--branch\n \t\t\t--recurse-submodules\n \t\t\t--no-single-branch\ndiff --git a/t/t5612-clone-refspec.sh b/t/t5612-clone-refspec.sh\nindex 97c847fab6..fac5a73851 100755\n--- a/t/t5612-clone-refspec.sh\n+++ b/t/t5612-clone-refspec.sh\n@@ -17,13 +17,20 @@ test_expect_success 'setup' '\n \techo four >file &&\n \tgit commit -a -m four &&\n \tgit checkout master &&\n+\tgit tag five &&\n \n \t# default clone\n \tgit clone . dir_all &&\n \n+\t# default clone --no-tags\n+\tgit clone --no-tags . dir_all_no_tags &&\n+\n \t# default --single that follows HEAD=master\n \tgit clone --single-branch . dir_master &&\n \n+\t# default --single that follows HEAD=master with no tags\n+\tgit clone --single-branch --no-tags . dir_master_no_tags &&\n+\n \t# default --single that follows HEAD=side\n \tgit checkout side &&\n \tgit clone --single-branch . dir_side &&\n@@ -45,6 +52,9 @@ test_expect_success 'setup' '\n \t# explicit --single with tag\n \tgit clone --single-branch --branch two . dir_tag &&\n \n+\t# explicit --single with tag and --no-tags\n+\tgit clone --single-branch --no-tags --branch two . dir_tag_no_tags &&\n+\n \t# advance both \"master\" and \"side\" branches\n \tgit checkout side &&\n \techo five >file &&\n@@ -77,7 +87,18 @@ test_expect_success 'by default no tags will be kept updated' '\n \t\tgit for-each-ref refs/tags >../actual\n \t) &&\n \tgit for-each-ref refs/tags >expect &&\n-\ttest_must_fail test_cmp expect actual\n+\ttest_must_fail test_cmp expect actual &&\n+\ttest_line_count = 2 actual\n+'\n+\n+test_expect_success 'clone with --no-tags' '\n+\t(\n+\t\tcd dir_all_no_tags &&\n+\t\tgit fetch &&\n+\t\tgit for-each-ref refs/tags >../actual\n+\t) &&\n+\t>expect &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success '--single-branch while HEAD pointing at master' '\n@@ -90,7 +111,47 @@ test_expect_success '--single-branch while HEAD pointing at master' '\n \t) &&\n \t# only follow master\n \tgit for-each-ref refs/heads/master >expect &&\n-\ttest_cmp expect actual\n+\t# get & check latest tags\n+\ttest_cmp expect actual &&\n+\t(\n+\t\tcd dir_master &&\n+\t\tgit fetch --tags &&\n+\t\tgit for-each-ref refs/tags >../actual\n+\t) &&\n+\tgit for-each-ref refs/tags >expect &&\n+\ttest_cmp expect actual &&\n+\ttest_line_count = 2 actual\n+'\n+\n+test_expect_success '--single-branch while HEAD pointing at master and --no-tags' '\n+\t(\n+\t\tcd dir_master_no_tags &&\n+\t\tgit fetch &&\n+\t\tgit for-each-ref refs/remotes/origin |\n+\t\tsed -e \"/HEAD$/d\" \\\n+\t\t    -e \"s|/remotes/origin/|/heads/|\" >../actual\n+\t) &&\n+\t# only follow master\n+\tgit for-each-ref refs/heads/master >expect &&\n+\ttest_cmp expect actual &&\n+\t# get tags (noop)\n+\t(\n+\t\tcd dir_master_no_tags &&\n+\t\tgit fetch &&\n+\t\tgit for-each-ref refs/tags >../actual\n+\t) &&\n+\t>expect &&\n+\ttest_cmp expect actual &&\n+\ttest_line_count = 0 actual &&\n+\t# get tags with --tags overrides tagOpt\n+\t(\n+\t\tcd dir_master_no_tags &&\n+\t\tgit fetch --tags &&\n+\t\tgit for-each-ref refs/tags >../actual\n+\t) &&\n+\tgit for-each-ref refs/tags >expect &&\n+\ttest_cmp expect actual &&\n+\ttest_line_count = 2 actual\n '\n \n test_expect_success '--single-branch while HEAD pointing at side' '\n@@ -129,6 +190,17 @@ test_expect_success '--single-branch with explicit --branch with tag fetches upd\n \ttest_cmp expect actual\n '\n \n+test_expect_success '--single-branch with explicit --branch with tag fetches updated tag despite --no-tags' '\n+\t(\n+\t\tcd dir_tag_no_tags &&\n+\t\tgit fetch &&\n+\t\tgit for-each-ref refs/tags >../actual\n+\t) &&\n+\tgit for-each-ref refs/tags/two >expect &&\n+\ttest_cmp expect actual &&\n+\ttest_line_count = 1 actual\n+'\n+\n test_expect_success '--single-branch with --mirror' '\n \t(\n \t\tcd dir_mirror &&\n-- \n2.11.0\n\n"},{"id":"318011","messageId":"20170426231236.27219-4-avarab@gmail.com","threadId":"45811","inReplyTo":"20170426231236.27219-1-avarab@gmail.com","subject":"[PATCH v3 3/5] tests: rename a test having to do with shallow submodules","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-04-26T23:12:34Z","receivedAt":"2017-04-26T23:13:11Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rename the t5614-clone-submodules.sh test to\nt5614-clone-submodules-shallow.sh. It's not a general test of\nsubmodules, but of shallow cloning in relation to submodules. Move it\nto create another similar t56*-clone-submodules-*.sh test.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} | 0\n 1 file changed, 0 insertions(+), 0 deletions(-)\n rename t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} (100%)\n\ndiff --git a/t/t5614-clone-submodules.sh b/t/t5614-clone-submodules-shallow.sh\nsimilarity index 100%\nrename from t/t5614-clone-submodules.sh\nrename to t/t5614-clone-submodules-shallow.sh\n-- \n2.11.0\n\n"},{"id":"318012","messageId":"20170426231236.27219-5-avarab@gmail.com","threadId":"45811","inReplyTo":"20170426231236.27219-1-avarab@gmail.com","subject":"[PATCH v3 4/5] clone: add a --no-tags-submodules to pass --no-tags to submodules","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-04-26T23:12:35Z","receivedAt":"2017-04-26T23:13:20Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"From: Brandon Williams <bmwill@google.com>\n\nAdd a --no-tags-submodules which does for --no-tags what the existing\n--shallow-submodules does for --depth, i.e. doing:\n\n    git clone --recurse-submodules --no-tags --no-tags-submodules <url>\n\nWill clone the superproject and all submodules with --no-tags\nsemantics.\n\nThis change does not implement a submodule.*.tags config .gitmodules\nconfiguration option corresponding to the existing submodule.*.shallow\nfacility, which would make --no-tags have full feature parity with\n--shallow-submodules.\n\nSigned-off-by: Brandon Williams <bmwill@google.com>\nCode-by: Brandon Williams <bmwill@google.com>\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nCommit-message-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nGit-Completion-Code-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nDocs-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nTests-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-clone.txt            | 11 +++++-\n builtin/clone.c                        |  6 +++\n builtin/submodule--helper.c            | 16 ++++++--\n contrib/completion/git-completion.bash |  1 +\n git-submodule.sh                       |  4 ++\n t/t5616-clone-submodules-tags.sh       | 72 ++++++++++++++++++++++++++++++++++\n 6 files changed, 106 insertions(+), 4 deletions(-)\n create mode 100755 t/t5616-clone-submodules-tags.sh\n\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex 83c8e9b394..4a0e4aa4f4 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -13,7 +13,8 @@ SYNOPSIS\n \t  [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]\n \t  [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]\n \t  [--dissociate] [--separate-git-dir <git dir>]\n-\t  [--depth <depth>] [--[no-]single-branch] [--no-tags]\n+\t  [--depth <depth>] [--[no-]single-branch]\n+\t  [--no-tags] [--no-tags-submodules]\n \t  [--recurse-submodules] [--[no-]shallow-submodules]\n \t  [--jobs <n>] [--] <repository> [<directory>]\n \n@@ -226,6 +227,10 @@ Can be used in conjunction with `--single-branch` to clone and\n maintain a branch with no references other than a single cloned\n branch. This is useful e.g. to maintain minimal clones of the default\n branch of some repository for search indexing.\n++\n+\n+If you want to clone submodules without tags provide the\n+`--no-tags-submodules` option.\n \n --recurse-submodules[=<pathspec]::\n \tAfter the clone is created, initialize and clone submodules\n@@ -243,6 +248,10 @@ branch of some repository for search indexing.\n --[no-]shallow-submodules::\n \tAll submodules which are cloned will be shallow with a depth of 1.\n \n+--no-tags-submodules::\n+\tAll submodules which are cloned will be cloned with the\n+\t`--no-tags` option.\n+\n --separate-git-dir=<git dir>::\n \tInstead of placing the cloned repository where it is supposed\n \tto be, place the cloned repository at the specified directory,\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 05f52d6f2b..5a945777a8 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -42,6 +42,7 @@ static int option_no_checkout, option_bare, option_mirror, option_single_branch\n static int option_local = -1, option_no_hardlinks, option_shared;\n static int option_no_tags;\n static int option_shallow_submodules;\n+static int option_no_tags_submodules;\n static int deepen;\n static char *option_template, *option_depth, *option_since;\n static char *option_origin = NULL;\n@@ -125,6 +126,8 @@ static struct option builtin_clone_options[] = {\n \t\t N_(\"don't clone any tags, and make later fetches not to follow them\")),\n \tOPT_BOOL(0, \"shallow-submodules\", &option_shallow_submodules,\n \t\t    N_(\"any cloned submodules will be shallow\")),\n+\tOPT_BOOL(0, \"no-tags-submodules\", &option_no_tags_submodules,\n+\t\t     N_(\"any cloned submodules will have no tags\")),\n \tOPT_STRING(0, \"separate-git-dir\", &real_git_dir, N_(\"gitdir\"),\n \t\t   N_(\"separate git dir from working tree\")),\n \tOPT_STRING_LIST('c', \"config\", &option_config, N_(\"key=value\"),\n@@ -761,6 +764,9 @@ static int checkout(int submodule_progress)\n \t\tif (option_shallow_submodules == 1)\n \t\t\targv_array_push(&args, \"--depth=1\");\n \n+\t\tif (option_no_tags_submodules)\n+\t\t\targv_array_push(&args, \"--no-tags\");\n+\n \t\tif (max_jobs != -1)\n \t\t\targv_array_pushf(&args, \"--jobs=%d\", max_jobs);\n \ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 36e4231821..caa4d252ee 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -489,7 +489,7 @@ static int module_name(int argc, const char **argv, const char *prefix)\n \n static int clone_submodule(const char *path, const char *gitdir, const char *url,\n \t\t\t   const char *depth, struct string_list *reference,\n-\t\t\t   int quiet, int progress)\n+\t\t\t   int quiet, int progress, int no_tags)\n {\n \tstruct child_process cp = CHILD_PROCESS_INIT;\n \n@@ -499,6 +499,8 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url\n \t\targv_array_push(&cp.args, \"--quiet\");\n \tif (progress)\n \t\targv_array_push(&cp.args, \"--progress\");\n+\tif (no_tags)\n+\t\targv_array_push(&cp.args, \"--no-tags\");\n \tif (depth && *depth)\n \t\targv_array_pushl(&cp.args, \"--depth\", depth, NULL);\n \tif (reference->nr) {\n@@ -623,6 +625,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \tstruct strbuf sb = STRBUF_INIT;\n \tstruct string_list reference = STRING_LIST_INIT_NODUP;\n \tchar *sm_alternate = NULL, *error_strategy = NULL;\n+\tint no_tags = 0;\n \n \tstruct option module_clone_options[] = {\n \t\tOPT_STRING(0, \"prefix\", &prefix,\n@@ -643,6 +646,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \t\tOPT_STRING(0, \"depth\", &depth,\n \t\t\t   N_(\"string\"),\n \t\t\t   N_(\"depth for shallow clones\")),\n+\t\tOPT_BOOL(0, \"no-tags\", &no_tags,\n+\t\t\t N_(\"don't clone any tags, and make later fetches not to follow them\")),\n \t\tOPT__QUIET(&quiet, \"Suppress output for cloning a submodule\"),\n \t\tOPT_BOOL(0, \"progress\", &progress,\n \t\t\t   N_(\"force cloning progress\")),\n@@ -680,7 +685,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \t\tprepare_possible_alternates(name, &reference);\n \n \t\tif (clone_submodule(path, sm_gitdir, url, depth, &reference,\n-\t\t\t\t    quiet, progress))\n+\t\t\t\t    quiet, progress, no_tags))\n \t\t\tdie(_(\"clone of '%s' into submodule path '%s' failed\"),\n \t\t\t    url, path);\n \t} else {\n@@ -745,11 +750,12 @@ struct submodule_update_clone {\n \t/* failed clones to be retried again */\n \tconst struct cache_entry **failed_clones;\n \tint failed_clones_nr, failed_clones_alloc;\n+\tint no_tags;\n };\n #define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \\\n \tSUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, \\\n \tNULL, NULL, NULL, \\\n-\tSTRING_LIST_INIT_DUP, 0, NULL, 0, 0}\n+\tSTRING_LIST_INIT_DUP, 0, NULL, 0, 0, 0}\n \n \n static void next_submodule_warn_missing(struct submodule_update_clone *suc,\n@@ -849,6 +855,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,\n \t\targv_array_pushl(&child->args, \"--prefix\", suc->prefix, NULL);\n \tif (suc->recommend_shallow && sub->recommend_shallow == 1)\n \t\targv_array_push(&child->args, \"--depth=1\");\n+\tif (suc->no_tags)\n+\t\targv_array_push(&child->args, \"--no-tags\");\n \targv_array_pushl(&child->args, \"--path\", sub->path, NULL);\n \targv_array_pushl(&child->args, \"--name\", sub->name, NULL);\n \targv_array_pushl(&child->args, \"--url\", sub->url, NULL);\n@@ -988,6 +996,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)\n \t\t\t    N_(\"parallel jobs\")),\n \t\tOPT_BOOL(0, \"recommend-shallow\", &suc.recommend_shallow,\n \t\t\t    N_(\"whether the initial clone should follow the shallow recommendation\")),\n+\t\tOPT_BOOL(0, \"no-tags\", &suc.no_tags,\n+\t\t\t N_(\"don't clone any tags, and make later fetches not to follow them\")),\n \t\tOPT__QUIET(&suc.quiet, N_(\"don't print cloning progress\")),\n \t\tOPT_BOOL(0, \"progress\", &suc.progress,\n \t\t\t    N_(\"force cloning progress\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6da997cf42..08fb1319c3 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1314,6 +1314,7 @@ _git_clone ()\n \t\t\t--recurse-submodules\n \t\t\t--no-single-branch\n \t\t\t--shallow-submodules\n+\t\t\t--no-tags-submodules\n \t\t\t\"\n \t\treturn\n \t\t;;\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex c0d0e9a4c6..3371775b0b 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -565,6 +565,9 @@ cmd_update()\n \t\t--depth=*)\n \t\t\tdepth=$1\n \t\t\t;;\n+\t\t--no-tags)\n+\t\t\tno_tags=1\n+\t\t\t;;\n \t\t-j|--jobs)\n \t\t\tcase \"$2\" in '') usage ;; esac\n \t\t\tjobs=\"--jobs=$2\"\n@@ -601,6 +604,7 @@ cmd_update()\n \t\t${reference:+\"$reference\"} \\\n \t\t${depth:+--depth \"$depth\"} \\\n \t\t${recommend_shallow:+\"$recommend_shallow\"} \\\n+\t\t${no_tags:+--no-tags} \\\n \t\t${jobs:+$jobs} \\\n \t\t\"$@\" || echo \"#unmatched\" $?\n \t} | {\ndiff --git a/t/t5616-clone-submodules-tags.sh b/t/t5616-clone-submodules-tags.sh\nnew file mode 100755\nindex 0000000000..3c88265352\n--- /dev/null\n+++ b/t/t5616-clone-submodules-tags.sh\n@@ -0,0 +1,72 @@\n+#!/bin/sh\n+\n+test_description='Test cloning of repos with submodules & the --[no-]tags option'\n+\n+. ./test-lib.sh\n+\n+pwd=$(pwd)\n+\n+test_expect_success 'setup' '\n+\tgit checkout -b master &&\n+\ttest_commit commit1 &&\n+\ttest_commit commit2 &&\n+\tmkdir sub &&\n+\t(\n+\t\tcd sub &&\n+\t\tgit init &&\n+\t\ttest_commit subcommit1 &&\n+\t\ttest_commit subcommit2 &&\n+\t\ttest_commit subcommit3\n+\t) &&\n+\tgit submodule add \"file://$pwd/sub\" sub &&\n+\tgit commit -m \"add submodule\" &&\n+\tgit tag addsubcommit1\n+'\n+\n+test_expect_success 'tags clone implies tags submodule' '\n+\ttest_when_finished \"rm -rf super_clone\" &&\n+\tgit clone --recurse-submodules \"file://$pwd/.\" super_clone &&\n+\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 3 tags &&\n+\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 3 tags\n+'\n+\n+test_expect_success 'no-tags clone with no-tags submodule' '\n+\ttest_when_finished \"rm -rf super_clone\" &&\n+\tgit clone --recurse-submodules --no-tags --no-tags-submodules \"file://$pwd/.\" super_clone &&\n+\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 0 tags &&\n+\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 0 tags\n+\n+'\n+\n+test_expect_success 'no-tags clone does not imply no-tags submodule' '\n+\ttest_when_finished \"rm -rf super_clone\" &&\n+\tgit clone --recurse-submodules --no-tags \"file://$pwd/.\" super_clone &&\n+\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 0 tags &&\n+\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 3 tags\n+'\n+\n+test_expect_success 'no-tags clone with tags submodule' '\n+\ttest_when_finished \"rm -rf super_clone\" &&\n+\tgit clone --recurse-submodules --no-tags --tags-submodules \"file://$pwd/.\" super_clone &&\n+\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 0 tags &&\n+\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 3 tags\n+'\n+\n+test_expect_success 'tags clone with no-tags submodule' '\n+\ttest_when_finished \"rm -rf super_clone\" &&\n+\tgit clone --recurse-submodules --tags --no-tags-submodules \"file://$pwd/.\" super_clone &&\n+\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 3 tags &&\n+\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 0 tags\n+'\n+\n+test_done\n-- \n2.11.0\n\n"},{"id":"318013","messageId":"20170426231236.27219-6-avarab@gmail.com","threadId":"45811","inReplyTo":"20170426231236.27219-1-avarab@gmail.com","subject":"[RFC/PATCH v3 5/5] WIP clone: add a --[no-]recommend-tags & submodule.NAME.tags config","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-04-26T23:12:36Z","receivedAt":"2017-04-26T23:13:22Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a --no-recommend-tags option & support for\nsubmodule.NAME.tags=[true|false] config facility. This does for\n--no-tags what --no-recommend-shallow & submodule.NAME.shallow does\nfor --shallow-submodules.\n\nThis is almost exactly the same code change as in Stefan Beller's\ncommit abed000aca (\"submodule update: learn `--[no-]recommend-shallow`\noption\", 2016-05-26) & 37f52e9344 (\"submodule-config: keep shallow\nrecommendation around\", 2016-05-26).\n\nThe difference in the configuration facility is that setting\nsubmodule.NAME.tags=false will turn on --no-tags, i.e. \"false\" means\n\"don't give me tags\", with \"true\" being the default.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-submodule.txt        |  8 +++++++-\n builtin/submodule--helper.c            |  7 +++++--\n contrib/completion/git-completion.bash |  1 +\n git-submodule.sh                       |  9 ++++++++-\n submodule-config.c                     |  8 ++++++++\n submodule-config.h                     |  1 +\n t/t5616-clone-submodules-tags.sh       | 34 ++++++++++++++++++++++++++++++++++\n 7 files changed, 64 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 74bc6200d5..9a431a833d 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -159,7 +159,7 @@ instead of deinit-ing everything, to prevent mistakes.\n If `--force` is specified, the submodule's working tree will\n be removed even if it contains local modifications.\n \n-update [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [-f|--force] [--checkout|--rebase|--merge] [--reference <repository>] [--depth <depth>] [--recursive] [--jobs <n>] [--] [<path>...]::\n+update [--init] [--remote] [-N|--no-fetch] [--[no-]recommend-shallow] [--[no-]recommend-tags] [-f|--force] [--checkout|--rebase|--merge] [--reference <repository>] [--depth <depth>] [--recursive] [--jobs <n>] [--] [<path>...]::\n +\n --\n Update the registered submodules to match what the superproject\n@@ -416,6 +416,12 @@ for linkgit:git-clone[1]'s `--reference` and `--shared` options carefully.\n \t`submodule.<name>.shallow` as provided by the .gitmodules file\n \tby default. To ignore the suggestions use `--no-recommend-shallow`.\n \n+--[no-]recommend-tags::\n+\tThis option is only valid for the update command.\n+\tThe initial clone of a submodule will use the recommended\n+\t`submodule.<name>.tags` as provided by the .gitmodules file\n+\tby default. To ignore the suggestions use `--no-recommend-tags`.\n+\n -j <n>::\n --jobs <n>::\n \tThis option is only valid for the update command.\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex caa4d252ee..424ea7a680 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -736,6 +736,7 @@ struct submodule_update_clone {\n \tint progress;\n \tint quiet;\n \tint recommend_shallow;\n+\tint recommend_tags;\n \tstruct string_list references;\n \tconst char *depth;\n \tconst char *recursive_prefix;\n@@ -753,7 +754,7 @@ struct submodule_update_clone {\n \tint no_tags;\n };\n #define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \\\n-\tSUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, \\\n+\tSUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, -1, STRING_LIST_INIT_DUP, \\\n \tNULL, NULL, NULL, \\\n \tSTRING_LIST_INIT_DUP, 0, NULL, 0, 0, 0}\n \n@@ -855,7 +856,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,\n \t\targv_array_pushl(&child->args, \"--prefix\", suc->prefix, NULL);\n \tif (suc->recommend_shallow && sub->recommend_shallow == 1)\n \t\targv_array_push(&child->args, \"--depth=1\");\n-\tif (suc->no_tags)\n+\tif (suc->no_tags || suc->recommend_tags == 0)\n \t\targv_array_push(&child->args, \"--no-tags\");\n \targv_array_pushl(&child->args, \"--path\", sub->path, NULL);\n \targv_array_pushl(&child->args, \"--name\", sub->name, NULL);\n@@ -996,6 +997,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)\n \t\t\t    N_(\"parallel jobs\")),\n \t\tOPT_BOOL(0, \"recommend-shallow\", &suc.recommend_shallow,\n \t\t\t    N_(\"whether the initial clone should follow the shallow recommendation\")),\n+\t\tOPT_BOOL(0, \"recommend-tags\", &suc.recommend_tags,\n+\t\t\t    N_(\"whether the initial clone should follow the tags recommendation\")),\n \t\tOPT_BOOL(0, \"no-tags\", &suc.no_tags,\n \t\t\t N_(\"don't clone any tags, and make later fetches not to follow them\")),\n \t\tOPT__QUIET(&suc.quiet, N_(\"don't print cloning progress\")),\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 08fb1319c3..8eb32032a8 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2878,6 +2878,7 @@ _git_submodule ()\n \t\t__gitcomp \"\n \t\t\t--init --remote --no-fetch\n \t\t\t--recommend-shallow --no-recommend-shallow\n+\t\t\t--recommend-tags --no-recommend-tags\n \t\t\t--force --rebase --merge --reference --depth --recursive --jobs\n \t\t\"\n \t\t;;\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 3371775b0b..5b204a9679 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -9,7 +9,7 @@ USAGE=\"[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <re\n    or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]\n    or: $dashless [--quiet] init [--] [<path>...]\n    or: $dashless [--quiet] deinit [-f|--force] (--all| [--] <path>...)\n-   or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--] [<path>...]\n+   or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--[no-]recommend-tags] [--reference <repository>] [--recursive] [--] [<path>...]\n    or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]\n    or: $dashless [--quiet] foreach [--recursive] <command>\n    or: $dashless [--quiet] sync [--recursive] [--] [<path>...]\n@@ -557,6 +557,12 @@ cmd_update()\n \t\t--no-recommend-shallow)\n \t\t\trecommend_shallow=\"--no-recommend-shallow\"\n \t\t\t;;\n+\t\t--recommend-tags)\n+\t\t\trecommend_tags=\"--recommend-tags\"\n+\t\t\t;;\n+\t\t--no-recommend-tags)\n+\t\t\trecommend_tags=\"--no-recommend-tags\"\n+\t\t\t;;\n \t\t--depth)\n \t\t\tcase \"$2\" in '') usage ;; esac\n \t\t\tdepth=\"--depth=$2\"\n@@ -604,6 +610,7 @@ cmd_update()\n \t\t${reference:+\"$reference\"} \\\n \t\t${depth:+--depth \"$depth\"} \\\n \t\t${recommend_shallow:+\"$recommend_shallow\"} \\\n+\t\t${recommend_tags:+\"$recommend_tags\"} \\\n \t\t${no_tags:+--no-tags} \\\n \t\t${jobs:+$jobs} \\\n \t\t\"$@\" || echo \"#unmatched\" $?\ndiff --git a/submodule-config.c b/submodule-config.c\nindex 4f58491ddb..68fbd9d1f0 100644\n--- a/submodule-config.c\n+++ b/submodule-config.c\n@@ -202,6 +202,7 @@ static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache,\n \tsubmodule->ignore = NULL;\n \tsubmodule->branch = NULL;\n \tsubmodule->recommend_shallow = -1;\n+\tsubmodule->recommend_tags = -1;\n \n \thashcpy(submodule->gitmodules_sha1, gitmodules_sha1);\n \n@@ -385,6 +386,13 @@ static int parse_config(const char *var, const char *value, void *data)\n \t\telse\n \t\t\tsubmodule->recommend_shallow =\n \t\t\t\tgit_config_bool(var, value);\n+\t} else if (!strcmp(item.buf, \"tags\")) {\n+\t\tif (!me->overwrite && submodule->recommend_tags != -1)\n+\t\t\twarn_multiple_config(me->treeish_name, submodule->name,\n+\t\t\t\t\t     \"tags\");\n+\t\telse\n+\t\t\tsubmodule->recommend_tags =\n+\t\t\t\tgit_config_bool(var, value);\n \t} else if (!strcmp(item.buf, \"branch\")) {\n \t\tif (!me->overwrite && submodule->branch)\n \t\t\twarn_multiple_config(me->treeish_name, submodule->name,\ndiff --git a/submodule-config.h b/submodule-config.h\nindex d434ecdb45..be3c567803 100644\n--- a/submodule-config.h\n+++ b/submodule-config.h\n@@ -20,6 +20,7 @@ struct submodule {\n \t/* the sha1 blob id of the responsible .gitmodules file */\n \tunsigned char gitmodules_sha1[20];\n \tint recommend_shallow;\n+\tint recommend_tags;\n };\n \n extern int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);\ndiff --git a/t/t5616-clone-submodules-tags.sh b/t/t5616-clone-submodules-tags.sh\nindex 3c88265352..caded2fb24 100755\n--- a/t/t5616-clone-submodules-tags.sh\n+++ b/t/t5616-clone-submodules-tags.sh\n@@ -69,4 +69,38 @@ test_expect_success 'tags clone with no-tags submodule' '\n \ttest_line_count = 0 tags\n '\n \n+test_expect_success 'clone follows tags=false recommendation' '\n+\ttest_when_finished \"rm -rf super_clone\" &&\n+\tgit config -f .gitmodules submodule.sub.tags false &&\n+\tgit add .gitmodules &&\n+\tgit commit -m \"recommed no-tags for sub\" &&\n+\tgit clone --recurse-submodules --no-local \"file://$pwd/.\" super_clone &&\n+\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 3 tags &&\n+\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 0 tags\n+'\n+\n+test_expect_success 'get tags recommended no-tags submodule' '\n+\ttest_when_finished \"rm -rf super_clone\" &&\n+\tgit clone --no-local \"file://$pwd/.\" super_clone &&\n+\tgit -C super_clone submodule update --init --no-recommend-tags &&\n+\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 3 tags &&\n+\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 3 tags\n+'\n+\n+test_expect_success 'clone follows tags=true recommendation' '\n+\ttest_when_finished \"rm -rf super_clone\" &&\n+\tgit config -f .gitmodules submodule.sub.tags true &&\n+\tgit add .gitmodules &&\n+\tgit commit -m \"recommed tags for sub\" &&\n+\tgit clone --recurse-submodules --no-local \"file://$pwd/.\" super_clone &&\n+\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 3 tags &&\n+\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n+\ttest_line_count = 3 tags\n+'\n+\n test_done\n-- \n2.11.0\n\n"},{"id":"318025","messageId":"xmqqk266poih.fsf@gitster.mtv.corp.google.com","threadId":"45811","inReplyTo":"20170426231236.27219-5-avarab@gmail.com","subject":"Re: [PATCH v3 4/5] clone: add a --no-tags-submodules to pass --no-tags to submodules","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-04-27T02:34:14Z","receivedAt":"2017-04-27T02:34:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> From: Brandon Williams <bmwill@google.com>\n>\n> Add a --no-tags-submodules which does for --no-tags what the existing\n> --shallow-submodules does for --depth, i.e. doing:\n>\n>     git clone --recurse-submodules --no-tags --no-tags-submodules <url>\n>\n> Will clone the superproject and all submodules with --no-tags\n> semantics.\n>\n> This change does not implement a submodule.*.tags config .gitmodules\n> configuration option corresponding to the existing submodule.*.shallow\n> facility, which would make --no-tags have full feature parity with\n> --shallow-submodules.\n\nShouldn't --no-tags automatically propagate down to submodules in\n--recurse-submodules mode instead?  I know --shallow-submodules\nexists but it looks to me more a misdesigned interface, rather than\nsomething we want to mimic in a new option.\n\nThe design of the traditional \"git submodule\" support strived to\nkeep the superproject and its submodules distinct and separately\nmanaged as much as possible, and I view the motivation behind the\nrecent push of \"--recurse-submodules\" as an attempt to make them\nappear as seamless as possible, so I have a feeling that a new\noption (like \"--no-tags\") that is applied to the superproject, as\nlong as it also makes sense to use it in submodules, should\npropagate down in that mode by default (and most likely\nunconditionally).  Those who want finer granularity of control can\nuse the traditional \"work with superproject, and then initialize and\nupdate the submodules you are interested in in any way you want\nindividually\" mode anyway.\n\n> Signed-off-by: Brandon Williams <bmwill@google.com>\n> Code-by: Brandon Williams <bmwill@google.com>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Commit-message-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Git-Completion-Code-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Docs-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Tests-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n\nIs it just me who finds this way of attribution unwieldy?  I would\nhave expected to see something like this at the end\n\n\tThe main code is by Brandon, Ævar added the docs, tests and\n\tcompletion and wrapped them up into a commit with a log\n\tmessage.\n\nbefore two s-o-b.\n\n> ---\n>  Documentation/git-clone.txt            | 11 +++++-\n>  builtin/clone.c                        |  6 +++\n>  builtin/submodule--helper.c            | 16 ++++++--\n>  contrib/completion/git-completion.bash |  1 +\n>  git-submodule.sh                       |  4 ++\n>  t/t5616-clone-submodules-tags.sh       | 72 ++++++++++++++++++++++++++++++++++\n>  6 files changed, 106 insertions(+), 4 deletions(-)\n>  create mode 100755 t/t5616-clone-submodules-tags.sh\n>\n> diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\n> index 83c8e9b394..4a0e4aa4f4 100644\n> --- a/Documentation/git-clone.txt\n> +++ b/Documentation/git-clone.txt\n> @@ -13,7 +13,8 @@ SYNOPSIS\n>  \t  [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]\n>  \t  [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]\n>  \t  [--dissociate] [--separate-git-dir <git dir>]\n> -\t  [--depth <depth>] [--[no-]single-branch] [--no-tags]\n> +\t  [--depth <depth>] [--[no-]single-branch]\n> +\t  [--no-tags] [--no-tags-submodules]\n>  \t  [--recurse-submodules] [--[no-]shallow-submodules]\n>  \t  [--jobs <n>] [--] <repository> [<directory>]\n>  \n> @@ -226,6 +227,10 @@ Can be used in conjunction with `--single-branch` to clone and\n>  maintain a branch with no references other than a single cloned\n>  branch. This is useful e.g. to maintain minimal clones of the default\n>  branch of some repository for search indexing.\n> ++\n> +\n> +If you want to clone submodules without tags provide the\n> +`--no-tags-submodules` option.\n>  \n>  --recurse-submodules[=<pathspec]::\n>  \tAfter the clone is created, initialize and clone submodules\n> @@ -243,6 +248,10 @@ branch of some repository for search indexing.\n>  --[no-]shallow-submodules::\n>  \tAll submodules which are cloned will be shallow with a depth of 1.\n>  \n> +--no-tags-submodules::\n> +\tAll submodules which are cloned will be cloned with the\n> +\t`--no-tags` option.\n> +\n>  --separate-git-dir=<git dir>::\n>  \tInstead of placing the cloned repository where it is supposed\n>  \tto be, place the cloned repository at the specified directory,\n> diff --git a/builtin/clone.c b/builtin/clone.c\n> index 05f52d6f2b..5a945777a8 100644\n> --- a/builtin/clone.c\n> +++ b/builtin/clone.c\n> @@ -42,6 +42,7 @@ static int option_no_checkout, option_bare, option_mirror, option_single_branch\n>  static int option_local = -1, option_no_hardlinks, option_shared;\n>  static int option_no_tags;\n>  static int option_shallow_submodules;\n> +static int option_no_tags_submodules;\n>  static int deepen;\n>  static char *option_template, *option_depth, *option_since;\n>  static char *option_origin = NULL;\n> @@ -125,6 +126,8 @@ static struct option builtin_clone_options[] = {\n>  \t\t N_(\"don't clone any tags, and make later fetches not to follow them\")),\n>  \tOPT_BOOL(0, \"shallow-submodules\", &option_shallow_submodules,\n>  \t\t    N_(\"any cloned submodules will be shallow\")),\n> +\tOPT_BOOL(0, \"no-tags-submodules\", &option_no_tags_submodules,\n> +\t\t     N_(\"any cloned submodules will have no tags\")),\n>  \tOPT_STRING(0, \"separate-git-dir\", &real_git_dir, N_(\"gitdir\"),\n>  \t\t   N_(\"separate git dir from working tree\")),\n>  \tOPT_STRING_LIST('c', \"config\", &option_config, N_(\"key=value\"),\n> @@ -761,6 +764,9 @@ static int checkout(int submodule_progress)\n>  \t\tif (option_shallow_submodules == 1)\n>  \t\t\targv_array_push(&args, \"--depth=1\");\n>  \n> +\t\tif (option_no_tags_submodules)\n> +\t\t\targv_array_push(&args, \"--no-tags\");\n> +\n>  \t\tif (max_jobs != -1)\n>  \t\t\targv_array_pushf(&args, \"--jobs=%d\", max_jobs);\n>  \n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index 36e4231821..caa4d252ee 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -489,7 +489,7 @@ static int module_name(int argc, const char **argv, const char *prefix)\n>  \n>  static int clone_submodule(const char *path, const char *gitdir, const char *url,\n>  \t\t\t   const char *depth, struct string_list *reference,\n> -\t\t\t   int quiet, int progress)\n> +\t\t\t   int quiet, int progress, int no_tags)\n>  {\n>  \tstruct child_process cp = CHILD_PROCESS_INIT;\n>  \n> @@ -499,6 +499,8 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url\n>  \t\targv_array_push(&cp.args, \"--quiet\");\n>  \tif (progress)\n>  \t\targv_array_push(&cp.args, \"--progress\");\n> +\tif (no_tags)\n> +\t\targv_array_push(&cp.args, \"--no-tags\");\n>  \tif (depth && *depth)\n>  \t\targv_array_pushl(&cp.args, \"--depth\", depth, NULL);\n>  \tif (reference->nr) {\n> @@ -623,6 +625,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n>  \tstruct strbuf sb = STRBUF_INIT;\n>  \tstruct string_list reference = STRING_LIST_INIT_NODUP;\n>  \tchar *sm_alternate = NULL, *error_strategy = NULL;\n> +\tint no_tags = 0;\n>  \n>  \tstruct option module_clone_options[] = {\n>  \t\tOPT_STRING(0, \"prefix\", &prefix,\n> @@ -643,6 +646,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n>  \t\tOPT_STRING(0, \"depth\", &depth,\n>  \t\t\t   N_(\"string\"),\n>  \t\t\t   N_(\"depth for shallow clones\")),\n> +\t\tOPT_BOOL(0, \"no-tags\", &no_tags,\n> +\t\t\t N_(\"don't clone any tags, and make later fetches not to follow them\")),\n>  \t\tOPT__QUIET(&quiet, \"Suppress output for cloning a submodule\"),\n>  \t\tOPT_BOOL(0, \"progress\", &progress,\n>  \t\t\t   N_(\"force cloning progress\")),\n> @@ -680,7 +685,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n>  \t\tprepare_possible_alternates(name, &reference);\n>  \n>  \t\tif (clone_submodule(path, sm_gitdir, url, depth, &reference,\n> -\t\t\t\t    quiet, progress))\n> +\t\t\t\t    quiet, progress, no_tags))\n>  \t\t\tdie(_(\"clone of '%s' into submodule path '%s' failed\"),\n>  \t\t\t    url, path);\n>  \t} else {\n> @@ -745,11 +750,12 @@ struct submodule_update_clone {\n>  \t/* failed clones to be retried again */\n>  \tconst struct cache_entry **failed_clones;\n>  \tint failed_clones_nr, failed_clones_alloc;\n> +\tint no_tags;\n>  };\n>  #define SUBMODULE_UPDATE_CLONE_INIT {0, MODULE_LIST_INIT, 0, \\\n>  \tSUBMODULE_UPDATE_STRATEGY_INIT, 0, 0, -1, STRING_LIST_INIT_DUP, \\\n>  \tNULL, NULL, NULL, \\\n> -\tSTRING_LIST_INIT_DUP, 0, NULL, 0, 0}\n> +\tSTRING_LIST_INIT_DUP, 0, NULL, 0, 0, 0}\n>  \n>  \n>  static void next_submodule_warn_missing(struct submodule_update_clone *suc,\n> @@ -849,6 +855,8 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,\n>  \t\targv_array_pushl(&child->args, \"--prefix\", suc->prefix, NULL);\n>  \tif (suc->recommend_shallow && sub->recommend_shallow == 1)\n>  \t\targv_array_push(&child->args, \"--depth=1\");\n> +\tif (suc->no_tags)\n> +\t\targv_array_push(&child->args, \"--no-tags\");\n>  \targv_array_pushl(&child->args, \"--path\", sub->path, NULL);\n>  \targv_array_pushl(&child->args, \"--name\", sub->name, NULL);\n>  \targv_array_pushl(&child->args, \"--url\", sub->url, NULL);\n> @@ -988,6 +996,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)\n>  \t\t\t    N_(\"parallel jobs\")),\n>  \t\tOPT_BOOL(0, \"recommend-shallow\", &suc.recommend_shallow,\n>  \t\t\t    N_(\"whether the initial clone should follow the shallow recommendation\")),\n> +\t\tOPT_BOOL(0, \"no-tags\", &suc.no_tags,\n> +\t\t\t N_(\"don't clone any tags, and make later fetches not to follow them\")),\n>  \t\tOPT__QUIET(&suc.quiet, N_(\"don't print cloning progress\")),\n>  \t\tOPT_BOOL(0, \"progress\", &suc.progress,\n>  \t\t\t    N_(\"force cloning progress\")),\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 6da997cf42..08fb1319c3 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -1314,6 +1314,7 @@ _git_clone ()\n>  \t\t\t--recurse-submodules\n>  \t\t\t--no-single-branch\n>  \t\t\t--shallow-submodules\n> +\t\t\t--no-tags-submodules\n>  \t\t\t\"\n>  \t\treturn\n>  \t\t;;\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index c0d0e9a4c6..3371775b0b 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -565,6 +565,9 @@ cmd_update()\n>  \t\t--depth=*)\n>  \t\t\tdepth=$1\n>  \t\t\t;;\n> +\t\t--no-tags)\n> +\t\t\tno_tags=1\n> +\t\t\t;;\n>  \t\t-j|--jobs)\n>  \t\t\tcase \"$2\" in '') usage ;; esac\n>  \t\t\tjobs=\"--jobs=$2\"\n> @@ -601,6 +604,7 @@ cmd_update()\n>  \t\t${reference:+\"$reference\"} \\\n>  \t\t${depth:+--depth \"$depth\"} \\\n>  \t\t${recommend_shallow:+\"$recommend_shallow\"} \\\n> +\t\t${no_tags:+--no-tags} \\\n>  \t\t${jobs:+$jobs} \\\n>  \t\t\"$@\" || echo \"#unmatched\" $?\n>  \t} | {\n> diff --git a/t/t5616-clone-submodules-tags.sh b/t/t5616-clone-submodules-tags.sh\n> new file mode 100755\n> index 0000000000..3c88265352\n> --- /dev/null\n> +++ b/t/t5616-clone-submodules-tags.sh\n> @@ -0,0 +1,72 @@\n> +#!/bin/sh\n> +\n> +test_description='Test cloning of repos with submodules & the --[no-]tags option'\n> +\n> +. ./test-lib.sh\n> +\n> +pwd=$(pwd)\n> +\n> +test_expect_success 'setup' '\n> +\tgit checkout -b master &&\n> +\ttest_commit commit1 &&\n> +\ttest_commit commit2 &&\n> +\tmkdir sub &&\n> +\t(\n> +\t\tcd sub &&\n> +\t\tgit init &&\n> +\t\ttest_commit subcommit1 &&\n> +\t\ttest_commit subcommit2 &&\n> +\t\ttest_commit subcommit3\n> +\t) &&\n> +\tgit submodule add \"file://$pwd/sub\" sub &&\n> +\tgit commit -m \"add submodule\" &&\n> +\tgit tag addsubcommit1\n> +'\n> +\n> +test_expect_success 'tags clone implies tags submodule' '\n> +\ttest_when_finished \"rm -rf super_clone\" &&\n> +\tgit clone --recurse-submodules \"file://$pwd/.\" super_clone &&\n> +\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n> +\ttest_line_count = 3 tags &&\n> +\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n> +\ttest_line_count = 3 tags\n> +'\n> +\n> +test_expect_success 'no-tags clone with no-tags submodule' '\n> +\ttest_when_finished \"rm -rf super_clone\" &&\n> +\tgit clone --recurse-submodules --no-tags --no-tags-submodules \"file://$pwd/.\" super_clone &&\n> +\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n> +\ttest_line_count = 0 tags &&\n> +\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n> +\ttest_line_count = 0 tags\n> +\n> +'\n> +\n> +test_expect_success 'no-tags clone does not imply no-tags submodule' '\n> +\ttest_when_finished \"rm -rf super_clone\" &&\n> +\tgit clone --recurse-submodules --no-tags \"file://$pwd/.\" super_clone &&\n> +\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n> +\ttest_line_count = 0 tags &&\n> +\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n> +\ttest_line_count = 3 tags\n> +'\n> +\n> +test_expect_success 'no-tags clone with tags submodule' '\n> +\ttest_when_finished \"rm -rf super_clone\" &&\n> +\tgit clone --recurse-submodules --no-tags --tags-submodules \"file://$pwd/.\" super_clone &&\n> +\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n> +\ttest_line_count = 0 tags &&\n> +\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n> +\ttest_line_count = 3 tags\n> +'\n> +\n> +test_expect_success 'tags clone with no-tags submodule' '\n> +\ttest_when_finished \"rm -rf super_clone\" &&\n> +\tgit clone --recurse-submodules --tags --no-tags-submodules \"file://$pwd/.\" super_clone &&\n> +\tgit -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n> +\ttest_line_count = 3 tags &&\n> +\tgit -C super_clone/sub for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n> +\ttest_line_count = 0 tags\n> +'\n> +\n> +test_done\n"},{"id":"318070","messageId":"20170427163314.GC80265@google.com","threadId":"45811","inReplyTo":"xmqqk266poih.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v3 4/5] clone: add a --no-tags-submodules to pass --no-tags to submodules","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-04-27T16:33:14Z","receivedAt":"2017-04-27T16:33:22Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 04/26, Junio C Hamano wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n> \n> > From: Brandon Williams <bmwill@google.com>\n> >\n> > Add a --no-tags-submodules which does for --no-tags what the existing\n> > --shallow-submodules does for --depth, i.e. doing:\n> >\n> >     git clone --recurse-submodules --no-tags --no-tags-submodules <url>\n> >\n> > Will clone the superproject and all submodules with --no-tags\n> > semantics.\n> >\n> > This change does not implement a submodule.*.tags config .gitmodules\n> > configuration option corresponding to the existing submodule.*.shallow\n> > facility, which would make --no-tags have full feature parity with\n> > --shallow-submodules.\n> \n> Shouldn't --no-tags automatically propagate down to submodules in\n> --recurse-submodules mode instead?  I know --shallow-submodules\n> exists but it looks to me more a misdesigned interface, rather than\n> something we want to mimic in a new option.\n\nI agree, I would think that the --no-tags option should be propagated\ndown when --recurse-submodules is provided, without needed to provide\nanother option for that.  Thinking about the recursive case here\n(submodules in side of submodules) you would then need to propagate down\ntwo options, --no-tags and --no-tags-submodules, which feels a bit\nawkward.\n\n> The design of the traditional \"git submodule\" support strived to\n> keep the superproject and its submodules distinct and separately\n> managed as much as possible, and I view the motivation behind the\n> recent push of \"--recurse-submodules\" as an attempt to make them\n> appear as seamless as possible, so I have a feeling that a new\n> option (like \"--no-tags\") that is applied to the superproject, as\n> long as it also makes sense to use it in submodules, should\n> propagate down in that mode by default (and most likely\n> unconditionally).  Those who want finer granularity of control can\n> use the traditional \"work with superproject, and then initialize and\n> update the submodules you are interested in in any way you want\n> individually\" mode anyway.\n> \n> > Signed-off-by: Brandon Williams <bmwill@google.com>\n> > Code-by: Brandon Williams <bmwill@google.com>\n> > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> > Commit-message-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> > Git-Completion-Code-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> > Docs-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> > Tests-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> \n> Is it just me who finds this way of attribution unwieldy?  I would\n> have expected to see something like this at the end\n> \n> \tThe main code is by Brandon, Ævar added the docs, tests and\n> \tcompletion and wrapped them up into a commit with a log\n> \tmessage.\n> \n> before two s-o-b.\n\nYeah this looks a bit messy.  Ævar, you've spent much longer on this\ntopic than I have and should probably take authorship.  I mean I only\nspent a little bit cobbling together a patch that I never tested. :)\nYou're more than welcome to include my 'Signed-off-by' and/or a\n'Helped-by' line for this patch though.\n\n-- \nBrandon Williams\n"},{"id":"318080","messageId":"CAGZ79kbHuMpiavJ90kQLEL_AR0BEyArcZoEWAjPPhOFacN16YQ@mail.gmail.com","threadId":"45811","inReplyTo":"20170426231236.27219-3-avarab@gmail.com","subject":"Re: [PATCH v3 2/5] clone: add a --no-tags option to clone without tags","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-27T17:54:26Z","receivedAt":"2017-04-27T17:54:36Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Apr 26, 2017 at 4:12 PM, Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> Add a --no-tags option to clone without fetching any tags.\n>\n> Without this change there's no easy way to clone a repository without\n> also fetching its tags.\n>\n> When supplying --single-branch the primary remote branch will be\n> cloned, but in addition tags will be followed & retrieved. Now\n> --no-tags can be added --single-branch to clone a repository without\n> tags, and which only tracks a single upstream branch.\n>\n> This option works without --single-branch as well, and will do a\n> normal clone but not fetch any tags.\n>\n> Many git commands pay some fixed overhead as a function of the number\n> of references. E.g. creating ~40k tags in linux.git will cause a\n> command like `git log -1 >/dev/null` to run in over a second instead\n> of in a matter of milliseconds, in addition numerous other things will\n> slow down, e.g. \"git log <TAB>\" with the bash completion will slowly\n> show ~40k references instead of 1.\n>\n> The user might want to avoid all of that overhead to simply use a\n> repository like that to browse the \"master\" branch, or something like\n> a CI tool might want to keep that one branch up-to-date without caring\n> about any other references.\n>\n> Without this change the only way of accomplishing this was either by\n> manually tweaking the config in a fresh repository:\n>\n>     git init git &&\n>     cat >git/.git/config <<EOF &&\n>     [remote \"origin\"]\n>         url = git@github.com:git/git.git\n>         tagOpt = --no-tags\n>         fetch = +refs/heads/master:refs/remotes/origin/master\n>     [branch \"master\"]\n>         remote = origin\n>         merge = refs/heads/master\n>     EOF\n>     cd git &&\n>     git pull\n>\n> Which requires hardcoding the \"master\" name, which may not be the main\n> --single-branch would have retrieved, or alternatively by setting\n> tagOpt=--no-tags right after cloning & deleting any existing tags:\n>\n>     git clone --single-branch git@github.com:git/git.git &&\n>     cd git &&\n>     git config remote.origin.tagOpt --no-tags &&\n>     git tag -l | xargs git tag -d\n>\n> Which of course was also subtly buggy if --branch was pointed at a\n> tag, leaving the user in a detached head:\n>\n>     git clone --single-branch --branch v2.12.0 git@github.com:git/git.git &&\n>     cd git &&\n>     git config remote.origin.tagOpt --no-tags &&\n>     git tag -l | xargs git tag -d\n>\n> Now all this complexity becomes the much simpler:\n>\n>     git clone --single-branch --no-tags git@github.com:git/git.git\n>\n> Or in the case of cloning a single tag \"branch\":\n>\n>     git clone --single-branch --branch v2.12.0 --no-tags git@github.com:git/git.git\n>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n\nI like the option, though I dislike the implementation, specifically as you\nbrought up e.g. \"[PATCH] various: disallow --no-no-OPT for --no-opt options\".\n\nCan we have an option \"--tags\" instead, which is on by default\nand then you can negate it to --no-tags, without having to worry\nabout the no-no case.\n\nThe problem with tags is that they are in a shared name-space\nand not part of the remote refspec. If they were, the documentation\nwould be way easier, too going this way.\n\n> +--no-tags::\n> +       Don't clone any tags, and set\n> +       `remote.<remote>.tagOpt=--no-tags` in the config, ensuring\n> +       that future `git pull` and `git fetch` operations won't follow\n> +       any tags. Subsequent explicit tag fetches will still work,\n> +       (see linkgit:git-fetch[1]).\n> ++\n> +Can be used in conjunction with `--single-branch` to clone and\n> +maintain a branch with no references other than a single cloned\n> +branch. This is useful e.g. to maintain minimal clones of the default\n> +branch of some repository for search indexing.\n\nIn the future we may want to have '--depth' also imply --no-tags,\njust as it implies --single-branch.\n\n> @@ -652,7 +655,7 @@ static void update_remote_refs(const struct ref *refs,\n>\n>         if (refs) {\n>                 write_remote_refs(mapped_refs);\n> -               if (option_single_branch)\n> +               if (option_single_branch && !option_no_tags)\n\nI am debating if this needs to be an || instead of &&, as you would not\nwant to write the tags with \"--no-single-branch --no-tags\" ?\n\nThanks,\nStefan\n"},{"id":"318081","messageId":"CAGZ79ka1_eJEa56TU5v++1FKsGY=nvZ4rWBK1begKvqecH17mQ@mail.gmail.com","threadId":"45811","inReplyTo":"20170426231236.27219-4-avarab@gmail.com","subject":"Re: [PATCH v3 3/5] tests: rename a test having to do with shallow submodules","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-27T17:58:12Z","receivedAt":"2017-04-27T17:58:18Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Apr 26, 2017 at 4:12 PM, Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> Rename the t5614-clone-submodules.sh test to\n> t5614-clone-submodules-shallow.sh. It's not a general test of\n> submodules, but of shallow cloning in relation to submodules. Move it\n> to create another similar t56*-clone-submodules-*.sh test.\n>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} | 0\n>  1 file changed, 0 insertions(+), 0 deletions(-)\n>  rename t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} (100%)\n>\n> diff --git a/t/t5614-clone-submodules.sh b/t/t5614-clone-submodules-shallow.sh\n> similarity index 100%\n> rename from t/t5614-clone-submodules.sh\n> rename to t/t5614-clone-submodules-shallow.sh\n\nThanks for formatting the patches with rename detection. :)\nThe rename looks good.\n\nThanks,\nStefan\n"},{"id":"318082","messageId":"CAGZ79kbsRv058PVwaWNtxKOH2LFnGk=VFTtt39FTqujkbz5E5A@mail.gmail.com","threadId":"45811","inReplyTo":"20170426231236.27219-5-avarab@gmail.com","subject":"Re: [PATCH v3 4/5] clone: add a --no-tags-submodules to pass --no-tags to submodules","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-27T18:27:06Z","receivedAt":"2017-04-27T18:28:01Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Apr 26, 2017 at 4:12 PM, Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> From: Brandon Williams <bmwill@google.com>\n>\n> Add a --no-tags-submodules which does for --no-tags what the existing\n> --shallow-submodules does for --depth, i.e. doing:\n>\n>     git clone --recurse-submodules --no-tags --no-tags-submodules <url>\n>\n> Will clone the superproject and all submodules with --no-tags\n> semantics.\n\nMy gut reaction to this is that it is ugly and maybe we should rather have\na --no-tags[=<repo-spec>].\n\nWe have had the discussion for e.g. git-push, for which we would like to\nhave a way to specify to push the superproject, or some submodules or\nall of them, or just the superproject and changed submodules,\nsuch that there we have a \"git push --recurse-submodules= \\\n[check|on-demand|only|no]\" which comes close to what I mean by\n\"repo-spec\".\n\n> This change does not implement a submodule.*.tags config .gitmodules\n> configuration option corresponding to the existing submodule.*.shallow\n> facility, which would make --no-tags have full feature parity with\n> --shallow-submodules.\n\nOkay, that can be added later if desired.\n\n> Signed-off-by: Brandon Williams <bmwill@google.com>\n> Code-by: Brandon Williams <bmwill@google.com>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Commit-message-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Git-Completion-Code-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Docs-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> Tests-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n\nQuite a lot of collaboration. ;)\n\n> @@ -499,6 +499,8 @@ static int clone_submodule(const char *path, const char *gitdir, const char *url\n>                 argv_array_push(&cp.args, \"--quiet\");\n>         if (progress)\n>                 argv_array_push(&cp.args, \"--progress\");\n> +       if (no_tags)\n> +               argv_array_push(&cp.args, \"--no-tags\");\n\nHere you would need to also push --no-tags-submodules to keep it recursive?\n\n> diff --git a/t/t5616-clone-submodules-tags.sh b/t/t5616-clone-submodules-tags.sh\n> new file mode 100755\n> index 0000000000..3c88265352\n> --- /dev/null\n> +++ b/t/t5616-clone-submodules-tags.sh\n\nName is good as it describes the niche we're looking at.\n(previous commit sounded as if you wanted to introduce\na plain clone-submodules.sh)\n\n> @@ -0,0 +1,72 @@\n> +#!/bin/sh\n> +\n> +test_description='Test cloning of repos with submodules & the --[no-]tags option'\n> +\n> +. ./test-lib.sh\n> +\n> +pwd=$(pwd)\n> +\n> +test_expect_success 'setup' '\n> +       git checkout -b master &&\n> +       test_commit commit1 &&\n> +       test_commit commit2 &&\n> +       mkdir sub &&\n> +       (\n> +               cd sub &&\n> +               git init &&\n> +               test_commit subcommit1 &&\n> +               test_commit subcommit2 &&\n> +               test_commit subcommit3\n> +       ) &&\n\nThis can be written easier with\n\n    test_create_repo sub &&\n    test_commit -C sub subcommit1 &&\n    test_commit -C sub subcommit2 &&\n    test_commit -C sub subcommit3 &&\n\nMost submodule code thought naming a submodule\n\"sub\" was a good idea. I also wrote such code. But please\nlet's stop with this tradition. Name the submodule after your\nfavorite dish (that hopefully doesn't have \"sub\" in its name),\nas it is much easier to read the test code when there are fewer\nstrings \"sub\".\n\n\n> +       git submodule add \"file://$pwd/sub\" sub &&\n> +       git commit -m \"add submodule\" &&\n> +       git tag addsubcommit1\n> +'\n> +\n> +test_expect_success 'tags clone implies tags submodule' '\n> +       test_when_finished \"rm -rf super_clone\" &&\n> +       git clone --recurse-submodules \"file://$pwd/.\" super_clone &&\n> +       git -C super_clone for-each-ref --format=\"%(refname:strip=2)\" refs/tags/ >tags &&\n\nWhy do we need to strip the refnames here? Full ref names ought to be fine?\nSpecifically when testing in combination of single-branch (does that imply\nany tags setting), I'd rather expect an rstrip and then counting refs/heads\nand refs/tags.\n\nThanks,\nStefan\n"},{"id":"318084","messageId":"CAGZ79kadPPBxW01p8KFGrcj3XwT1VZCcNTG4O_vxpU5n-ZRPFA@mail.gmail.com","threadId":"45811","inReplyTo":"20170426231236.27219-6-avarab@gmail.com","subject":"Re: [RFC/PATCH v3 5/5] WIP clone: add a --[no-]recommend-tags & submodule.NAME.tags config","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-27T19:36:01Z","receivedAt":"2017-04-27T19:36:07Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Apr 26, 2017 at 4:12 PM, Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n\n> @@ -855,7 +856,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,\n>                 argv_array_pushl(&child->args, \"--prefix\", suc->prefix, NULL);\n>         if (suc->recommend_shallow && sub->recommend_shallow == 1)\n>                 argv_array_push(&child->args, \"--depth=1\");\n> -       if (suc->no_tags)\n> +       if (suc->no_tags || suc->recommend_tags == 0)\n>                 argv_array_push(&child->args, \"--no-tags\");\n\nHere you would also need to pay attention to sub->recommend_tags?\n"},{"id":"318099","messageId":"20170427221231.GA146047@google.com","threadId":"45811","inReplyTo":"CAGZ79kbHuMpiavJ90kQLEL_AR0BEyArcZoEWAjPPhOFacN16YQ@mail.gmail.com","subject":"Re: [PATCH v3 2/5] clone: add a --no-tags option to clone without tags","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-04-27T22:12:31Z","receivedAt":"2017-04-27T22:12:54Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 04/27, Stefan Beller wrote:\n> I like the option, though I dislike the implementation, specifically as you\n> brought up e.g. \"[PATCH] various: disallow --no-no-OPT for --no-opt options\".\n> \n> Can we have an option \"--tags\" instead, which is on by default\n> and then you can negate it to --no-tags, without having to worry\n> about the no-no case.\n\nYeah I agree that a \"--tags\" option would make the ui cleaner.\n\n-- \nBrandon Williams\n"},{"id":"318100","messageId":"20170427221337.GB146047@google.com","threadId":"45811","inReplyTo":"CAGZ79ka1_eJEa56TU5v++1FKsGY=nvZ4rWBK1begKvqecH17mQ@mail.gmail.com","subject":"Re: [PATCH v3 3/5] tests: rename a test having to do with shallow submodules","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-04-27T22:13:37Z","receivedAt":"2017-04-27T22:14:00Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 04/27, Stefan Beller wrote:\n> On Wed, Apr 26, 2017 at 4:12 PM, Ævar Arnfjörð Bjarmason\n> <avarab@gmail.com> wrote:\n> > Rename the t5614-clone-submodules.sh test to\n> > t5614-clone-submodules-shallow.sh. It's not a general test of\n> > submodules, but of shallow cloning in relation to submodules. Move it\n> > to create another similar t56*-clone-submodules-*.sh test.\n> >\n> > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> > ---\n> >  t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} | 0\n> >  1 file changed, 0 insertions(+), 0 deletions(-)\n> >  rename t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} (100%)\n> >\n> > diff --git a/t/t5614-clone-submodules.sh b/t/t5614-clone-submodules-shallow.sh\n> > similarity index 100%\n> > rename from t/t5614-clone-submodules.sh\n> > rename to t/t5614-clone-submodules-shallow.sh\n> \n> Thanks for formatting the patches with rename detection. :)\n> The rename looks good.\n\nDo you have to turn that on or is that on by default?\n\n-- \nBrandon Williams\n"},{"id":"318101","messageId":"20170427221931.GC146047@google.com","threadId":"45811","inReplyTo":"CAGZ79kbsRv058PVwaWNtxKOH2LFnGk=VFTtt39FTqujkbz5E5A@mail.gmail.com","subject":"Re: [PATCH v3 4/5] clone: add a --no-tags-submodules to pass --no-tags to submodules","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-04-27T22:19:31Z","receivedAt":"2017-04-27T22:19:39Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 04/27, Stefan Beller wrote:\n> On Wed, Apr 26, 2017 at 4:12 PM, Ævar Arnfjörð Bjarmason\n> <avarab@gmail.com> wrote:\n> > From: Brandon Williams <bmwill@google.com>\n> >\n> > Add a --no-tags-submodules which does for --no-tags what the existing\n> > --shallow-submodules does for --depth, i.e. doing:\n> >\n> >     git clone --recurse-submodules --no-tags --no-tags-submodules <url>\n> >\n> > Will clone the superproject and all submodules with --no-tags\n> > semantics.\n> \n> My gut reaction to this is that it is ugly and maybe we should rather have\n> a --no-tags[=<repo-spec>].\n\nSee my gut reaction to that is: that's ugly :).  The --no-tags option\nshould just be propagated down (like I mentioned in another thread).\n\n> We have had the discussion for e.g. git-push, for which we would like to\n> have a way to specify to push the superproject, or some submodules or\n> all of them, or just the superproject and changed submodules,\n> such that there we have a \"git push --recurse-submodules= \\\n> [check|on-demand|only|no]\" which comes close to what I mean by\n> \"repo-spec\".\n\nThis makes more sense to me in terms of pushing...its still not my\nfavorite ui design but its what we have.\n\n-- \nBrandon Williams\n"},{"id":"318102","messageId":"20170427222700.GD146047@google.com","threadId":"45811","inReplyTo":"20170426231236.27219-1-avarab@gmail.com","subject":"Re: [PATCH v3 0/5] clone: --no-tags option","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-04-27T22:27:00Z","receivedAt":"2017-04-27T22:27:23Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 04/26, Ævar Arnfjörð Bjarmason wrote:\n> This is an expansion of the previously solo 02/05 \"clone: add a\n> --no-tags option to clone without tags\" patch (see\n> <20170418191553.15464-1-avarab@gmail.com>).\n> \n> This addresses the comments by Junio & Jonathan Nieder on v2 (thanks a\n> lot), and in addition implements a --no-tags-submodules option. That\n> code was implemented by Brandon & sent to me privately after I'd\n> failed to come up with it, but I added tests, a commit message & bash\n> completion to it.\n\nNa you would have come up with it, I've just lived in submodule land a\nlittle too long (though not as long as Stephan has!) :D\n\n> The WIP 5/5 patch implements a submodule.NAME.tags config facility for\n> the option, but is broken currently & floats along in this submission\n> as an RFC patch. AFAICT it *should* work and it goes through all the\n> motions the similar existing *.shallow config does, but for some\n> reason the tags=false option isn't picked up & propagated in a freshly\n> cloned submodule.\n> \n> I'm probably missing something trivial, but I can't see what it is,\n> I'm hoping thath either Stefan or Brandon will see what that is.\n\nOverall the series looks good.  I've mentioned in the other threads that\nit probably makes more sense to have --recurse-submodules simply pass\nthrough known good commands to its children (e.g. --no-tags) simply\nbecause it makes the UX a little bit easier to work with (I don't have\nto remember all the fancy --OPT-submodules stuff, only\n--recurse-submodules).  That is unless you have some good rational that\nI'm not considering (completely possible :D).\n\n> \n> Brandon Williams (1):\n>   clone: add a --no-tags-submodules to pass --no-tags to submodules\n> \n> Ævar Arnfjörð Bjarmason (4):\n>   tests: change \"cd ... && git fetch\" to \"cd &&\\n\\tgit fetch\"\n>   clone: add a --no-tags option to clone without tags\n>   tests: rename a test having to do with shallow submodules\n>   WIP clone: add a --[no-]recommend-tags & submodule.NAME.tags config\n> \n>  Documentation/git-clone.txt                        |  21 ++++\n>  Documentation/git-submodule.txt                    |   8 +-\n>  builtin/clone.c                                    |  19 +++-\n>  builtin/submodule--helper.c                        |  21 +++-\n>  contrib/completion/git-completion.bash             |   3 +\n>  git-submodule.sh                                   |  13 ++-\n>  submodule-config.c                                 |   8 ++\n>  submodule-config.h                                 |   1 +\n>  t/t5612-clone-refspec.sh                           | 103 +++++++++++++++++---\n>  ...odules.sh => t5614-clone-submodules-shallow.sh} |   0\n>  t/t5616-clone-submodules-tags.sh                   | 106 +++++++++++++++++++++\n>  11 files changed, 284 insertions(+), 19 deletions(-)\n>  rename t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} (100%)\n>  create mode 100755 t/t5616-clone-submodules-tags.sh\n> \n> -- \n> 2.11.0\n> \n\n-- \nBrandon Williams\n"},{"id":"318130","messageId":"CACBZZX7H5KwHXiQd=YFSuoY=VLMb7kXyaxDQg-iiiBb=DL8X8w@mail.gmail.com","threadId":"45811","inReplyTo":"20170427222700.GD146047@google.com","subject":"Re: [PATCH v3 0/5] clone: --no-tags option","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-04-28T08:57:40Z","receivedAt":"2017-04-28T08:58:20Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Fri, Apr 28, 2017 at 12:27 AM, Brandon Williams <bmwill@google.com> wrote:\n> On 04/26, Ævar Arnfjörð Bjarmason wrote:\n>> This is an expansion of the previously solo 02/05 \"clone: add a\n>> --no-tags option to clone without tags\" patch (see\n>> <20170418191553.15464-1-avarab@gmail.com>).\n>>\n>> This addresses the comments by Junio & Jonathan Nieder on v2 (thanks a\n>> lot), and in addition implements a --no-tags-submodules option. That\n>> code was implemented by Brandon & sent to me privately after I'd\n>> failed to come up with it, but I added tests, a commit message & bash\n>> completion to it.\n>\n> Na you would have come up with it, I've just lived in submodule land a\n> little too long (though not as long as Stephan has!) :D\n>\n>> The WIP 5/5 patch implements a submodule.NAME.tags config facility for\n>> the option, but is broken currently & floats along in this submission\n>> as an RFC patch. AFAICT it *should* work and it goes through all the\n>> motions the similar existing *.shallow config does, but for some\n>> reason the tags=false option isn't picked up & propagated in a freshly\n>> cloned submodule.\n>>\n>> I'm probably missing something trivial, but I can't see what it is,\n>> I'm hoping thath either Stefan or Brandon will see what that is.\n>\n> Overall the series looks good.  I've mentioned in the other threads that\n> it probably makes more sense to have --recurse-submodules simply pass\n> through known good commands to its children (e.g. --no-tags) simply\n> because it makes the UX a little bit easier to work with (I don't have\n> to remember all the fancy --OPT-submodules stuff, only\n> --recurse-submodules).  That is unless you have some good rational that\n> I'm not considering (completely possible :D).\n\nI have no good (or bad) reason for that other than just wanting to add\n--no-tags to submodules while I was at it, and then I was just\nfollowing the pattern the option to pass along --depth was\nestablishing.\n\nBut if that's some anti-pattern and the consensus is that this\nsubmodule feature should instead work as you describe (which looks\nlike the case) I'll change it to work like that.\n\n>>\n>> Brandon Williams (1):\n>>   clone: add a --no-tags-submodules to pass --no-tags to submodules\n>>\n>> Ævar Arnfjörð Bjarmason (4):\n>>   tests: change \"cd ... && git fetch\" to \"cd &&\\n\\tgit fetch\"\n>>   clone: add a --no-tags option to clone without tags\n>>   tests: rename a test having to do with shallow submodules\n>>   WIP clone: add a --[no-]recommend-tags & submodule.NAME.tags config\n>>\n>>  Documentation/git-clone.txt                        |  21 ++++\n>>  Documentation/git-submodule.txt                    |   8 +-\n>>  builtin/clone.c                                    |  19 +++-\n>>  builtin/submodule--helper.c                        |  21 +++-\n>>  contrib/completion/git-completion.bash             |   3 +\n>>  git-submodule.sh                                   |  13 ++-\n>>  submodule-config.c                                 |   8 ++\n>>  submodule-config.h                                 |   1 +\n>>  t/t5612-clone-refspec.sh                           | 103 +++++++++++++++++---\n>>  ...odules.sh => t5614-clone-submodules-shallow.sh} |   0\n>>  t/t5616-clone-submodules-tags.sh                   | 106 +++++++++++++++++++++\n>>  11 files changed, 284 insertions(+), 19 deletions(-)\n>>  rename t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} (100%)\n>>  create mode 100755 t/t5616-clone-submodules-tags.sh\n>>\n>> --\n>> 2.11.0\n>>\n>\n> --\n> Brandon Williams\n"},{"id":"318131","messageId":"CACBZZX7VHURHOoRMmcJq1e-pv7x3gKhYyWF5F5X+FgbunY-xhA@mail.gmail.com","threadId":"45811","inReplyTo":"20170427221337.GB146047@google.com","subject":"Re: [PATCH v3 3/5] tests: rename a test having to do with shallow submodules","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-04-28T08:59:22Z","receivedAt":"2017-04-28T08:59:50Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Fri, Apr 28, 2017 at 12:13 AM, Brandon Williams <bmwill@google.com> wrote:\n> On 04/27, Stefan Beller wrote:\n>> On Wed, Apr 26, 2017 at 4:12 PM, Ævar Arnfjörð Bjarmason\n>> <avarab@gmail.com> wrote:\n>> > Rename the t5614-clone-submodules.sh test to\n>> > t5614-clone-submodules-shallow.sh. It's not a general test of\n>> > submodules, but of shallow cloning in relation to submodules. Move it\n>> > to create another similar t56*-clone-submodules-*.sh test.\n>> >\n>> > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> > ---\n>> >  t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} | 0\n>> >  1 file changed, 0 insertions(+), 0 deletions(-)\n>> >  rename t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} (100%)\n>> >\n>> > diff --git a/t/t5614-clone-submodules.sh b/t/t5614-clone-submodules-shallow.sh\n>> > similarity index 100%\n>> > rename from t/t5614-clone-submodules.sh\n>> > rename to t/t5614-clone-submodules-shallow.sh\n>>\n>> Thanks for formatting the patches with rename detection. :)\n>> The rename looks good.\n>\n> Do you have to turn that on or is that on by default?\n\nLooks like it just uses the diff.renames setting which I don't tweak,\nI didn't do anything special, but maybe it picked up some part of my\n.gitconfig that doesn't look like it has anything to do with\nrenames...\n"},{"id":"318180","messageId":"CACBZZX5dxaJDN18J5fAhjKcaP8cZSTtRw5-eScr2oq8OYyhKuQ@mail.gmail.com","threadId":"45811","inReplyTo":"CAGZ79kbHuMpiavJ90kQLEL_AR0BEyArcZoEWAjPPhOFacN16YQ@mail.gmail.com","subject":"Re: [PATCH v3 2/5] clone: add a --no-tags option to clone without tags","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-04-28T14:44:59Z","receivedAt":"2017-04-28T14:45:26Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, Apr 27, 2017 at 7:54 PM, Stefan Beller <sbeller@google.com> wrote:\n> On Wed, Apr 26, 2017 at 4:12 PM, Ævar Arnfjörð Bjarmason\n> <avarab@gmail.com> wrote:\n>> Add a --no-tags option to clone without fetching any tags.\n>>\n>> Without this change there's no easy way to clone a repository without\n>> also fetching its tags.\n>>\n>> When supplying --single-branch the primary remote branch will be\n>> cloned, but in addition tags will be followed & retrieved. Now\n>> --no-tags can be added --single-branch to clone a repository without\n>> tags, and which only tracks a single upstream branch.\n>>\n>> This option works without --single-branch as well, and will do a\n>> normal clone but not fetch any tags.\n>>\n>> Many git commands pay some fixed overhead as a function of the number\n>> of references. E.g. creating ~40k tags in linux.git will cause a\n>> command like `git log -1 >/dev/null` to run in over a second instead\n>> of in a matter of milliseconds, in addition numerous other things will\n>> slow down, e.g. \"git log <TAB>\" with the bash completion will slowly\n>> show ~40k references instead of 1.\n>>\n>> The user might want to avoid all of that overhead to simply use a\n>> repository like that to browse the \"master\" branch, or something like\n>> a CI tool might want to keep that one branch up-to-date without caring\n>> about any other references.\n>>\n>> Without this change the only way of accomplishing this was either by\n>> manually tweaking the config in a fresh repository:\n>>\n>>     git init git &&\n>>     cat >git/.git/config <<EOF &&\n>>     [remote \"origin\"]\n>>         url = git@github.com:git/git.git\n>>         tagOpt = --no-tags\n>>         fetch = +refs/heads/master:refs/remotes/origin/master\n>>     [branch \"master\"]\n>>         remote = origin\n>>         merge = refs/heads/master\n>>     EOF\n>>     cd git &&\n>>     git pull\n>>\n>> Which requires hardcoding the \"master\" name, which may not be the main\n>> --single-branch would have retrieved, or alternatively by setting\n>> tagOpt=--no-tags right after cloning & deleting any existing tags:\n>>\n>>     git clone --single-branch git@github.com:git/git.git &&\n>>     cd git &&\n>>     git config remote.origin.tagOpt --no-tags &&\n>>     git tag -l | xargs git tag -d\n>>\n>> Which of course was also subtly buggy if --branch was pointed at a\n>> tag, leaving the user in a detached head:\n>>\n>>     git clone --single-branch --branch v2.12.0 git@github.com:git/git.git &&\n>>     cd git &&\n>>     git config remote.origin.tagOpt --no-tags &&\n>>     git tag -l | xargs git tag -d\n>>\n>> Now all this complexity becomes the much simpler:\n>>\n>>     git clone --single-branch --no-tags git@github.com:git/git.git\n>>\n>> Or in the case of cloning a single tag \"branch\":\n>>\n>>     git clone --single-branch --branch v2.12.0 --no-tags git@github.com:git/git.git\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>\n> I like the option, though I dislike the implementation, specifically as you\n> brought up e.g. \"[PATCH] various: disallow --no-no-OPT for --no-opt options\".\n>\n> Can we have an option \"--tags\" instead, which is on by default\n> and then you can negate it to --no-tags, without having to worry\n> about the no-no case.\n>\n> The problem with tags is that they are in a shared name-space\n> and not part of the remote refspec. If they were, the documentation\n> would be way easier, too going this way.\n\nI don't mind doing it this way, but this really should be part of an\nunrelated topic to eliminate --no-OPT in favor of just --OPT which is\nsupplied by default, if we want to go that route.\n\nRight now it makes more sense to have a --no-tags, because this along\nwith e.g. --no-hardlinks and numerous other options[1] is for an\nobscure use-case most users won't care about, and then we have &\ndocument --no-BEHAVIOR.\n\nPerhaps we shouldn't have that at all, go through all these --no-OPT\nand replace them with --OPT in both the docs & code & get rid of the\n--no-no-OPT & some confusion that way.\n\n1. git grep -- '\\[--no-' Documentation/git-*txt\n\n>> +--no-tags::\n>> +       Don't clone any tags, and set\n>> +       `remote.<remote>.tagOpt=--no-tags` in the config, ensuring\n>> +       that future `git pull` and `git fetch` operations won't follow\n>> +       any tags. Subsequent explicit tag fetches will still work,\n>> +       (see linkgit:git-fetch[1]).\n>> ++\n>> +Can be used in conjunction with `--single-branch` to clone and\n>> +maintain a branch with no references other than a single cloned\n>> +branch. This is useful e.g. to maintain minimal clones of the default\n>> +branch of some repository for search indexing.\n>\n> In the future we may want to have '--depth' also imply --no-tags,\n> just as it implies --single-branch.\n\nAre there some cases where we'd like to also somehow import & rewrite\ntags covering the given --depth?\n\n>> @@ -652,7 +655,7 @@ static void update_remote_refs(const struct ref *refs,\n>>\n>>         if (refs) {\n>>                 write_remote_refs(mapped_refs);\n>> -               if (option_single_branch)\n>> +               if (option_single_branch && !option_no_tags)\n>\n> I am debating if this needs to be an || instead of &&, as you would not\n> want to write the tags with \"--no-single-branch --no-tags\" ?\n\nThis hunk is confusing out of context, but I believe it's doing the\nright thing now. This write_followtags() codepath is only taken (and\nis only meaningful) with --single-branch, there's an earlier change\njust before that:\n\n    -       if (!option_mirror && !option_single_branch)\n    +       if (!option_mirror && !option_single_branch && !option_no_tags)\n                    get_fetch_map(refs, tag_refspec, &tail, 0);\n\nWhich ensures that with --no-single-branch --no-tags that tags aren't\nwritten, and there's tests for that.\n"},{"id":"318192","messageId":"CAGZ79kYYXKmiJUshss0E+L8qqBX=qt636Az3_0iZX2ZW8oojdg@mail.gmail.com","threadId":"45811","inReplyTo":"CACBZZX7VHURHOoRMmcJq1e-pv7x3gKhYyWF5F5X+FgbunY-xhA@mail.gmail.com","subject":"Re: [PATCH v3 3/5] tests: rename a test having to do with shallow submodules","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-28T17:50:29Z","receivedAt":"2017-04-28T17:52:21Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Fri, Apr 28, 2017 at 1:59 AM, Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> On Fri, Apr 28, 2017 at 12:13 AM, Brandon Williams <bmwill@google.com> wrote:\n>> On 04/27, Stefan Beller wrote:\n>>> On Wed, Apr 26, 2017 at 4:12 PM, Ævar Arnfjörð Bjarmason\n>>> <avarab@gmail.com> wrote:\n>>> > Rename the t5614-clone-submodules.sh test to\n>>> > t5614-clone-submodules-shallow.sh. It's not a general test of\n>>> > submodules, but of shallow cloning in relation to submodules. Move it\n>>> > to create another similar t56*-clone-submodules-*.sh test.\n>>> >\n>>> > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>>> > ---\n>>> >  t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} | 0\n>>> >  1 file changed, 0 insertions(+), 0 deletions(-)\n>>> >  rename t/{t5614-clone-submodules.sh => t5614-clone-submodules-shallow.sh} (100%)\n>>> >\n>>> > diff --git a/t/t5614-clone-submodules.sh b/t/t5614-clone-submodules-shallow.sh\n>>> > similarity index 100%\n>>> > rename from t/t5614-clone-submodules.sh\n>>> > rename to t/t5614-clone-submodules-shallow.sh\n>>>\n>>> Thanks for formatting the patches with rename detection. :)\n>>> The rename looks good.\n>>\n>> Do you have to turn that on or is that on by default?\n>\n> Looks like it just uses the diff.renames setting which I don't tweak,\n> I didn't do anything special, but maybe it picked up some part of my\n> .gitconfig that doesn't look like it has anything to do with\n> renames...\n\nAfter reading the man page of format-patch, I do not think you'd need\nto configure anything special as the default settings easily pickup\na rename with 100% similarity.  It is only hairy when changes are in\nthere as well, then you may want to play around with -B/-M.\n\nThanks,\nStefan\n"},{"id":"318194","messageId":"CACBZZX7bHai-CTiO1G1vOP41Uit3zeMAn64NKvA73aouoBWMng@mail.gmail.com","threadId":"45811","inReplyTo":"20170426231236.27219-1-avarab@gmail.com","subject":"Re: [PATCH v3 0/5] clone: --no-tags option","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-04-28T19:11:20Z","receivedAt":"2017-04-28T19:11:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, Apr 27, 2017 at 1:12 AM, Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> This is an expansion of the previously solo 02/05 \"clone: add a\n> --no-tags option to clone without tags\" patch (see\n> <20170418191553.15464-1-avarab@gmail.com>).\n>\n> This addresses the comments by Junio & Jonathan Nieder on v2 (thanks a\n> lot), and in addition implements a --no-tags-submodules option. That\n> code was implemented by Brandon & sent to me privately after I'd\n> failed to come up with it, but I added tests, a commit message & bash\n> completion to it.\n>\n> The WIP 5/5 patch implements a submodule.NAME.tags config facility for\n> the option, but is broken currently & floats along in this submission\n> as an RFC patch. AFAICT it *should* work and it goes through all the\n> motions the similar existing *.shallow config does, but for some\n> reason the tags=false option isn't picked up & propagated in a freshly\n> cloned submodule.\n>\n> I'm probably missing something trivial, but I can't see what it is,\n> I'm hoping thath either Stefan or Brandon will see what that is.\n\nJunio, can you please just take patch 1-3 in this series, i.e.:\n\nDROP:\n\n> Brandon Williams (1):\n>   clone: add a --no-tags-submodules to pass --no-tags to submodules\n> [...]\n>   WIP clone: add a --[no-]recommend-tags & submodule.NAME.tags config\n\nKEEP:\n\n> Ævar Arnfjörð Bjarmason (4):\n>   tests: change \"cd ... && git fetch\" to \"cd &&\\n\\tgit fetch\"\n>   clone: add a --no-tags option to clone without tags\n>   tests: rename a test having to do with shallow submodules\n\nI think a fair summary of the discussion so far is that the submodule\ninteraction I copy/pasted from --shallow-submodules isn't how we want\nto do things at all, I defer to Stefan & Brandon on that.\n\nThe only other objection to the patches marked as KEEP is from Stefan\nsaying it should be --tags on by default not --no-tags off by default.\nAs noted in <CACBZZX5dxaJDN18J5fAhjKcaP8cZSTtRw5-eScr2oq8OYyhKuQ@mail.gmail.com>\nI don't disagree, but a lot of flags in git now use that pattern, and\nthis change is consistent with those. Makes sense to discuss changing\nthat as another series.\n"},{"id":"318195","messageId":"CAGZ79kbrn-wY27V+DQ2h0T8Xm02rFuXhw0rnP_0qo_q5oBd8TA@mail.gmail.com","threadId":"45811","inReplyTo":"CACBZZX7bHai-CTiO1G1vOP41Uit3zeMAn64NKvA73aouoBWMng@mail.gmail.com","subject":"Re: [PATCH v3 0/5] clone: --no-tags option","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-04-28T19:16:14Z","receivedAt":"2017-04-28T19:16:35Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Fri, Apr 28, 2017 at 12:11 PM, Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> On Thu, Apr 27, 2017 at 1:12 AM, Ævar Arnfjörð Bjarmason\n> <avarab@gmail.com> wrote:\n>> This is an expansion of the previously solo 02/05 \"clone: add a\n>> --no-tags option to clone without tags\" patch (see\n>> <20170418191553.15464-1-avarab@gmail.com>).\n>>\n>> This addresses the comments by Junio & Jonathan Nieder on v2 (thanks a\n>> lot), and in addition implements a --no-tags-submodules option. That\n>> code was implemented by Brandon & sent to me privately after I'd\n>> failed to come up with it, but I added tests, a commit message & bash\n>> completion to it.\n>>\n>> The WIP 5/5 patch implements a submodule.NAME.tags config facility for\n>> the option, but is broken currently & floats along in this submission\n>> as an RFC patch. AFAICT it *should* work and it goes through all the\n>> motions the similar existing *.shallow config does, but for some\n>> reason the tags=false option isn't picked up & propagated in a freshly\n>> cloned submodule.\n>>\n>> I'm probably missing something trivial, but I can't see what it is,\n>> I'm hoping thath either Stefan or Brandon will see what that is.\n>\n> Junio, can you please just take patch 1-3 in this series, i.e.:\n>\n> DROP:\n>\n>> Brandon Williams (1):\n>>   clone: add a --no-tags-submodules to pass --no-tags to submodules\n>> [...]\n>>   WIP clone: add a --[no-]recommend-tags & submodule.NAME.tags config\n>\n> KEEP:\n>\n>> Ævar Arnfjörð Bjarmason (4):\n>>   tests: change \"cd ... && git fetch\" to \"cd &&\\n\\tgit fetch\"\n>>   clone: add a --no-tags option to clone without tags\n>>   tests: rename a test having to do with shallow submodules\n>\n> I think a fair summary of the discussion so far is that the submodule\n> interaction I copy/pasted from --shallow-submodules isn't how we want\n> to do things at all, I defer to Stefan & Brandon on that.\n\nok. In that case we'd want to discuss what we actually want with no-tags\nin submodules.\n\n>\n> The only other objection to the patches marked as KEEP is from Stefan\n> saying it should be --tags on by default not --no-tags off by default.\n> As noted in <CACBZZX5dxaJDN18J5fAhjKcaP8cZSTtRw5-eScr2oq8OYyhKuQ@mail.gmail.com>\n> I don't disagree, but a lot of flags in git now use that pattern, and\n> this change is consistent with those. Makes sense to discuss changing\n> that as another series.\n\nOk. I assumed with that next series on the radar, we'd not want to intentionally\nadd more of the no-OPTIONs as that would produce more work for that series.\n"},{"id":"318279","messageId":"xmqqa86xjrbt.fsf@gitster.mtv.corp.google.com","threadId":"45811","inReplyTo":"CACBZZX7bHai-CTiO1G1vOP41Uit3zeMAn64NKvA73aouoBWMng@mail.gmail.com","subject":"Re: [PATCH v3 0/5] clone: --no-tags option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-01T01:31:18Z","receivedAt":"2017-05-01T01:41:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> Junio, can you please just take patch 1-3 in this series, i.e.:\n\nGiven that the old one has been already sitting in 'next' since\nApril 23rd, I'd have to revert it and requeue them anew.  Which is\npossible but cumbersome,...\n\nLet me take a look at these three patches and then decide what to\ndo.  Thanks.\n"}]}