"git clone" learned the "--no-tags" option not to fetch all tags
initially, and also set up the tagopt not to follow any tags in
subsequent fetches.
* ab/clone-no-tags:
tests: rename a test having to do with shallow submodules
clone: add a --no-tags option to clone without tags
tests: change "cd ... && git fetch" to "cd &&\n\tgit fetch"
@ -215,6 +215,18 @@ objects from the source repository into a pack in the cloned repository.
@@ -215,6 +215,18 @@ objects from the source repository into a pack in the cloned repository.
branch when `--single-branch` clone was made, no remote-tracking
branch is created.
--no-tags::
Don't clone any tags, and set
`remote.<remote>.tagOpt=--no-tags` in the config, ensuring
that future `git pull` and `git fetch` operations won't follow
any tags. Subsequent explicit tag fetches will still work,
(see linkgit:git-fetch[1]).
+
Can be used in conjunction with `--single-branch` to clone and
maintain a branch with no references other than a single cloned
branch. This is useful e.g. to maintain minimal clones of the default
branch of some repository for search indexing.
--recurse-submodules[=<pathspec]::
After the clone is created, initialize and clone submodules
within based on the provided pathspec. If no pathspec is
test_expect_success 'by default all branches will be kept updated' '
(
cd dir_all && git fetch &&
cd dir_all &&
git fetch &&
git for-each-ref refs/remotes/origin |
sed -e "/HEAD$/d" \
-e "s|/remotes/origin/|/heads/|" >../actual
@ -71,28 +82,82 @@ test_expect_success 'by default all branches will be kept updated' '
@@ -71,28 +82,82 @@ test_expect_success 'by default all branches will be kept updated' '
test_expect_success 'by default no tags will be kept updated' '
(
cd dir_all && git fetch &&
cd dir_all &&
git fetch &&
git for-each-ref refs/tags >../actual
) &&
git for-each-ref refs/tags >expect &&
test_must_fail test_cmp expect actual
test_must_fail test_cmp expect actual &&
test_line_count = 2 actual
'
test_expect_success 'clone with --no-tags' '
(
cd dir_all_no_tags &&
git fetch &&
git for-each-ref refs/tags >../actual
) &&
>expect &&
test_cmp expect actual
'
test_expect_success '--single-branch while HEAD pointing at master' '
(
cd dir_master && git fetch &&
cd dir_master &&
git fetch &&
git for-each-ref refs/remotes/origin |
sed -e "/HEAD$/d" \
-e "s|/remotes/origin/|/heads/|" >../actual
) &&
# only follow master
git for-each-ref refs/heads/master >expect &&
test_cmp expect actual
# get & check latest tags
test_cmp expect actual &&
(
cd dir_master &&
git fetch --tags &&
git for-each-ref refs/tags >../actual
) &&
git for-each-ref refs/tags >expect &&
test_cmp expect actual &&
test_line_count = 2 actual
'
test_expect_success '--single-branch while HEAD pointing at master and --no-tags' '
(
cd dir_master_no_tags &&
git fetch &&
git for-each-ref refs/remotes/origin |
sed -e "/HEAD$/d" \
-e "s|/remotes/origin/|/heads/|" >../actual
) &&
# only follow master
git for-each-ref refs/heads/master >expect &&
test_cmp expect actual &&
# get tags (noop)
(
cd dir_master_no_tags &&
git fetch &&
git for-each-ref refs/tags >../actual
) &&
>expect &&
test_cmp expect actual &&
test_line_count = 0 actual &&
# get tags with --tags overrides tagOpt
(
cd dir_master_no_tags &&
git fetch --tags &&
git for-each-ref refs/tags >../actual
) &&
git for-each-ref refs/tags >expect &&
test_cmp expect actual &&
test_line_count = 2 actual
'
test_expect_success '--single-branch while HEAD pointing at side' '
(
cd dir_side && git fetch &&
cd dir_side &&
git fetch &&
git for-each-ref refs/remotes/origin |
sed -e "/HEAD$/d" \
-e "s|/remotes/origin/|/heads/|" >../actual
@ -104,7 +169,8 @@ test_expect_success '--single-branch while HEAD pointing at side' '
@@ -104,7 +169,8 @@ test_expect_success '--single-branch while HEAD pointing at side' '
test_expect_success '--single-branch with explicit --branch side' '