git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Beller <sbeller@google.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Brandon Williams" <bmwill@google.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Jonathan Nieder" <jrnieder@gmail.com>
Subject: Re: [PATCH v3 2/5] clone: add a --no-tags option to clone without tags
Date: Thu, 27 Apr 2017 10:54:26 -0700	[thread overview]
Message-ID: <CAGZ79kbHuMpiavJ90kQLEL_AR0BEyArcZoEWAjPPhOFacN16YQ@mail.gmail.com> (raw)
In-Reply-To: <20170426231236.27219-3-avarab@gmail.com>

On Wed, Apr 26, 2017 at 4:12 PM, Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
> Add a --no-tags option to clone without fetching any tags.
>
> Without this change there's no easy way to clone a repository without
> also fetching its tags.
>
> When supplying --single-branch the primary remote branch will be
> cloned, but in addition tags will be followed & retrieved. Now
> --no-tags can be added --single-branch to clone a repository without
> tags, and which only tracks a single upstream branch.
>
> This option works without --single-branch as well, and will do a
> normal clone but not fetch any tags.
>
> Many git commands pay some fixed overhead as a function of the number
> of references. E.g. creating ~40k tags in linux.git will cause a
> command like `git log -1 >/dev/null` to run in over a second instead
> of in a matter of milliseconds, in addition numerous other things will
> slow down, e.g. "git log <TAB>" with the bash completion will slowly
> show ~40k references instead of 1.
>
> The user might want to avoid all of that overhead to simply use a
> repository like that to browse the "master" branch, or something like
> a CI tool might want to keep that one branch up-to-date without caring
> about any other references.
>
> Without this change the only way of accomplishing this was either by
> manually tweaking the config in a fresh repository:
>
>     git init git &&
>     cat >git/.git/config <<EOF &&
>     [remote "origin"]
>         url = git@github.com:git/git.git
>         tagOpt = --no-tags
>         fetch = +refs/heads/master:refs/remotes/origin/master
>     [branch "master"]
>         remote = origin
>         merge = refs/heads/master
>     EOF
>     cd git &&
>     git pull
>
> Which requires hardcoding the "master" name, which may not be the main
> --single-branch would have retrieved, or alternatively by setting
> tagOpt=--no-tags right after cloning & deleting any existing tags:
>
>     git clone --single-branch git@github.com:git/git.git &&
>     cd git &&
>     git config remote.origin.tagOpt --no-tags &&
>     git tag -l | xargs git tag -d
>
> Which of course was also subtly buggy if --branch was pointed at a
> tag, leaving the user in a detached head:
>
>     git clone --single-branch --branch v2.12.0 git@github.com:git/git.git &&
>     cd git &&
>     git config remote.origin.tagOpt --no-tags &&
>     git tag -l | xargs git tag -d
>
> Now all this complexity becomes the much simpler:
>
>     git clone --single-branch --no-tags git@github.com:git/git.git
>
> Or in the case of cloning a single tag "branch":
>
>     git clone --single-branch --branch v2.12.0 --no-tags git@github.com:git/git.git
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>

I like the option, though I dislike the implementation, specifically as you
brought up e.g. "[PATCH] various: disallow --no-no-OPT for --no-opt options".

Can we have an option "--tags" instead, which is on by default
and then you can negate it to --no-tags, without having to worry
about the no-no case.

The problem with tags is that they are in a shared name-space
and not part of the remote refspec. If they were, the documentation
would be way easier, too going this way.

> +--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.

In the future we may want to have '--depth' also imply --no-tags,
just as it implies --single-branch.

> @@ -652,7 +655,7 @@ static void update_remote_refs(const struct ref *refs,
>
>         if (refs) {
>                 write_remote_refs(mapped_refs);
> -               if (option_single_branch)
> +               if (option_single_branch && !option_no_tags)

I am debating if this needs to be an || instead of &&, as you would not
want to write the tags with "--no-single-branch --no-tags" ?

Thanks,
Stefan

  reply	other threads:[~2017-04-27 17:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26 23:12 [PATCH v3 0/5] clone: --no-tags option Ævar Arnfjörð Bjarmason
2017-04-26 23:12 ` [PATCH v3 1/5] tests: change "cd ... && git fetch" to "cd &&\n\tgit fetch" Ævar Arnfjörð Bjarmason
2017-04-26 23:12 ` [PATCH v3 2/5] clone: add a --no-tags option to clone without tags Ævar Arnfjörð Bjarmason
2017-04-27 17:54   ` Stefan Beller [this message]
2017-04-27 22:12     ` Brandon Williams
2017-04-28 14:44     ` Ævar Arnfjörð Bjarmason
2017-04-26 23:12 ` [PATCH v3 3/5] tests: rename a test having to do with shallow submodules Ævar Arnfjörð Bjarmason
2017-04-27 17:58   ` Stefan Beller
2017-04-27 22:13     ` Brandon Williams
2017-04-28  8:59       ` Ævar Arnfjörð Bjarmason
2017-04-28 17:50         ` Stefan Beller
2017-04-26 23:12 ` [PATCH v3 4/5] clone: add a --no-tags-submodules to pass --no-tags to submodules Ævar Arnfjörð Bjarmason
2017-04-27  2:34   ` Junio C Hamano
2017-04-27 16:33     ` Brandon Williams
2017-04-27 18:27   ` Stefan Beller
2017-04-27 22:19     ` Brandon Williams
2017-04-26 23:12 ` [RFC/PATCH v3 5/5] WIP clone: add a --[no-]recommend-tags & submodule.NAME.tags config Ævar Arnfjörð Bjarmason
2017-04-27 19:36   ` Stefan Beller
2017-04-27 22:27 ` [PATCH v3 0/5] clone: --no-tags option Brandon Williams
2017-04-28  8:57   ` Ævar Arnfjörð Bjarmason
2017-04-28 19:11 ` Ævar Arnfjörð Bjarmason
2017-04-28 19:16   ` Stefan Beller
2017-05-01  1:31   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGZ79kbHuMpiavJ90kQLEL_AR0BEyArcZoEWAjPPhOFacN16YQ@mail.gmail.com \
    --to=sbeller@google.com \
    --cc=avarab@gmail.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).