git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Is it possible to git clone --filter= without any objects?
@ 2018-09-11  7:29 Ciro Santilli
  2018-09-11 17:15 ` Stefan Beller
  0 siblings, 1 reply; 6+ messages in thread
From: Ciro Santilli @ 2018-09-11  7:29 UTC (permalink / raw)
  To: git

At v2.19.0 I was trying to clone a fetch just a single directory:
https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository/52269934#52269934

I got really close with:

git clone --depth 1 --no-checkout --filter=blob:none \
  "file://$(pwd)/server_repo" local_repo
cd local_repo
git checkout master -- mydir/

The only missing thing is that uneeded tree objects are still being fetched.

If I had a:

git clone --filter=none

for example then that would be done.

Nothing major since those are small, but just looking for the perfect
command :-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible to git clone --filter= without any objects?
  2018-09-11  7:29 Is it possible to git clone --filter= without any objects? Ciro Santilli
@ 2018-09-11 17:15 ` Stefan Beller
  2018-09-11 17:19   ` Jonathan Tan
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Beller @ 2018-09-11 17:15 UTC (permalink / raw)
  To: Ciro Santilli, Matthew DeVore; +Cc: git

On Tue, Sep 11, 2018 at 12:29 AM Ciro Santilli <ciro.santilli@gmail.com> wrote:
>
> At v2.19.0 I was trying to clone a fetch just a single directory:
> https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository/52269934#52269934
>
> I got really close with:
>
> git clone --depth 1 --no-checkout --filter=blob:none \
>   "file://$(pwd)/server_repo" local_repo
> cd local_repo
> git checkout master -- mydir/
>
> The only missing thing is that uneeded tree objects are still being fetched.
>
> If I had a:
>
> git clone --filter=none
>
> for example then that would be done.
>
> Nothing major since those are small, but just looking for the perfect
> command :-)

You might be pleased to hear about a series floating on the mailing list,
that started at
https://public-inbox.org/git/cover.1533854545.git.matvore@google.com/
and promised to filter trees away, and its latest version can be found at
https://public-inbox.org/git/cover.1536081438.git.matvore@google.com/

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible to git clone --filter= without any objects?
  2018-09-11 17:15 ` Stefan Beller
@ 2018-09-11 17:19   ` Jonathan Tan
  2018-09-11 17:46     ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Tan @ 2018-09-11 17:19 UTC (permalink / raw)
  To: Stefan Beller; +Cc: Ciro Santilli, Matthew DeVore, git

On Tue, Sep 11, 2018 at 10:15 AM, Stefan Beller <sbeller@google.com> wrote:
> You might be pleased to hear about a series floating on the mailing list,
> that started at
> https://public-inbox.org/git/cover.1533854545.git.matvore@google.com/
> and promised to filter trees away, and its latest version can be found at
> https://public-inbox.org/git/cover.1536081438.git.matvore@google.com/

I mentioned this in an email to the original poster in which I forgot
to also CC the mailing list:

By "without any objects" in your email subject, do you mean "without
blob and tree objects"? If yes, there is some code in the
md/filter-trees branch that can do that with a "--filter=tree:0"
option. As far as I know, it is not yet in any released version of
Git, but hopefully will be in the next one (the "What's Cooking" [1]
email mentions that it will be merged to the "next" branch, which is
one of the steps before it is released).

[1] https://public-inbox.org/git/xmqqmusw6gbo.fsf@gitster-ct.c.googlers.com/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible to git clone --filter= without any objects?
  2018-09-11 17:19   ` Jonathan Tan
@ 2018-09-11 17:46     ` Junio C Hamano
  2018-09-11 18:29       ` Ciro Santilli
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2018-09-11 17:46 UTC (permalink / raw)
  To: Jonathan Tan; +Cc: Stefan Beller, Ciro Santilli, Matthew DeVore, git

Jonathan Tan <jonathantanmy@google.com> writes:

> By "without any objects" in your email subject, do you mean "without
> blob and tree objects"? If yes, there is some code in the
> md/filter-trees branch that can do that with a "--filter=tree:0"
> option.

I too was wondering what the "without any objects" thing meant
myself.

What would it take on top of the following sequence to create such
an ultra-lazy clone?

	$ mkdir very-sparse && cd very-sparse
	$ git init
	$ git remote add origin $URL

At this point, the repository does not have any object, but it
already knows whom to talk to to get the objects in the project.
The remote must be configured so that it is willing to feed you any
object you name, but would it be just some "git config" magic after
the above three steps to make it as if it was prepared with "git
clone --filter="?  If so, what does that magic look like?

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible to git clone --filter= without any objects?
  2018-09-11 17:46     ` Junio C Hamano
@ 2018-09-11 18:29       ` Ciro Santilli
  2018-09-12  1:12         ` Matthew DeVore
  0 siblings, 1 reply; 6+ messages in thread
From: Ciro Santilli @ 2018-09-11 18:29 UTC (permalink / raw)
  To: gitster; +Cc: jonathantanmy, sbeller, matvore, git

On Tue, Sep 11, 2018 at 6:47 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Jonathan Tan <jonathantanmy@google.com> writes:
>
> > By "without any objects" in your email subject, do you mean "without
> > blob and tree objects"? If yes, there is some code in the
> > md/filter-trees branch that can do that with a "--filter=tree:0"
> > option.
>
> I too was wondering what the "without any objects" thing meant
> myself.
>

Thanks for all replies, as you correctly deduced, I meant "without
fetching any objects".

The mentioned --filter=tree:0 would basically do what I want it seems,
good to hear!. I wonder why not call it tree:none though to match
blob:none.

> What would it take on top of the following sequence to create such
> an ultra-lazy clone?
>
>         $ mkdir very-sparse && cd very-sparse
>         $ git init
>         $ git remote add origin $URL
>

Yes, this would be a good CLI API since the since the clone
--no-checkout --filter --filter gets a bit long.

Or maybe:

git clone --lazy URL repo_local
cd repo_local
git checkout commit -- path/within/repo

Or maybe even:

git clene --lazy URL repo_local COMMITISH path/within/repo

to do both in one go.

People are also interested in commit-less directory / file "clones"
BTW: https://stackoverflow.com/questions/2466735/how-to-checkout-only-one-file-from-git-repository-sparse-checkout

> At this point, the repository does not have any object, but it
> already knows whom to talk to to get the objects in the project.
> The remote must be configured so that it is willing to feed you any
> object you name, but would it be just some "git config" magic after
> the above three steps to make it as if it was prepared with "git
> clone --filter="?  If so, what does that magic look like?
>
> Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Is it possible to git clone --filter= without any objects?
  2018-09-11 18:29       ` Ciro Santilli
@ 2018-09-12  1:12         ` Matthew DeVore
  0 siblings, 0 replies; 6+ messages in thread
From: Matthew DeVore @ 2018-09-12  1:12 UTC (permalink / raw)
  To: ciro.santilli; +Cc: Junio C Hamano, Jonathan Tan, Stefan Beller, git

On Tue, Sep 11, 2018 at 11:30 AM Ciro Santilli <ciro.santilli@gmail.com> wrote:
> The mentioned --filter=tree:0 would basically do what I want it seems,
> good to hear!. I wonder why not call it tree:none though to match
> blob:none.
There are some plans of making tree: accept positive integers in order
to filter out files greater than that depth. e.g. tree:1 would fetch
all blobs and tree objects directly contained by the tree. tree:2
would fetch every object tree:1 does plus anything referred to
directly by those objects.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-09-12  1:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-11  7:29 Is it possible to git clone --filter= without any objects? Ciro Santilli
2018-09-11 17:15 ` Stefan Beller
2018-09-11 17:19   ` Jonathan Tan
2018-09-11 17:46     ` Junio C Hamano
2018-09-11 18:29       ` Ciro Santilli
2018-09-12  1:12         ` Matthew DeVore

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).