Re: [PATCH] git clone depth of 0 not possible.

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] git clone depth of 0 not possible.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:55:41

Junio C Hamano [off-list ref] writes:
Jonathan Nieder [off-list ref] writes:
quoted
Stefan Beller wrote:
quoted
Currently it is not possible to have a shallow depth of
just 0, i.e. only one commit in that repository after cloning.
The minimum number of commits is 2, caused by depth=1.
Sounds buggy.  Would anything break if we were to make --depth=1 mean
"1 deep, including the tip commit"?
As long as we do not change the meaning of the "shallow" count going
over the wire (i.e. the number we receive from the user will be
fudged, so that user's "depth 1" that used to mean "the tip and one
behind it" is expressed as "depth 2" at the end-user level, and we
send over the wire the number that corresponded to the old "depth
1"), I do not think anything will break, and then --depth=0 may
magically start meaning "only the tip; its immediate parents will
not be transferred and recorded as the shallow boundary in the
receiving repository".

I do not mind carrying such a (technially) backward incompatible
change in jn/clone-2.0-depth-off-by-one branch, keep it cooking in
'next' for a while and push it out together with other "2.0" topics
in a future release ;-).
Speaking of --depth, I think in Git 2.0 we should fix the semantics
of "deepening" done with "git fetch".

Its "--depth" parameter is used to specify the new depth of the
history that you can tangle from the updated tip of remote tracking
branches, and it has a rather unpleasant ramifications.

Suppose you start from "git clone --depth=1 $there".  You have the
today's snapshot, and one parent behind it.  You keep working happily
with the code and then realize that you want to know a bit more
history behind the snapshot you started from.

 (upstream)
  ---o---o---o---A---B

 (you)
                 A---B

So you do:

    $ git fetch --depth=3

 (upstream)
  ---o---o---o---A---B---C---D---E---F---...---W---X---Y---Z

 (you)
                 A---B                         W---X---Y---Z

But in the meantime, if the upstream accumulated 20+ commits, you
end up getting the commit at the updated tip of the upstream, and 3
generations of parents behind it.  There will be a 10+ commit worth
of gap between the bottom of the new shallow history and the old tip
you have been working on, and the history becomes disjoint.

I think we need a protocol update to fix this; instead of sending
"Now I want your tips and N commits behind it, please update my
shallow bottom accordingly", which creates the above by giving you Z
and 3 generations back and updates your cut-off point to W, the
receiving end should be able to ask "I have a shallow history that
cuts off at these commits. I want to get the history leading up to
your tips, and also deepen the history further back from my current
cut-off points by N commits", so that you would instead end up with
something like this:

 (you)
     o---o---o---A---B---C---D---E---F---...---W---X---Y---Z

That is, truly "deepen my history by 3".  We could call that "git
fetch --deepen=3" or something.

Re: [PATCH] git clone depth of 0 not possible.

From: Duy Nguyen <hidden>
Date: 2016-06-15 22:55:41

On Tue, Jan 8, 2013 at 2:36 PM, Junio C Hamano [off-list ref] wrote:
Speaking of --depth, I think in Git 2.0 we should fix the semantics
of "deepening" done with "git fetch".
Speaking of 2.0, we should support depth per ref. Well we don't have
to wait until 2.0 because we could just add shallow2 extension to the
pack protocol. We should also apply depth to new refs when fetching
them the first time.
-- 
Duy

Re: [PATCH] git clone depth of 0 not possible.

From: Stefan Beller <hidden>
Date: 2016-06-15 22:55:41

On 01/08/2013 03:28 PM, Duy Nguyen wrote:
On Tue, Jan 8, 2013 at 2:36 PM, Junio C Hamano [off-list ref] wrote:
quoted
Speaking of --depth, I think in Git 2.0 we should fix the semantics
of "deepening" done with "git fetch".
Speaking of 2.0, we should support depth per ref. Well we don't have
to wait until 2.0 because we could just add shallow2 extension to the
pack protocol. We should also apply depth to new refs when fetching
them the first time.
Would this mean I could do something along?
$ git clone --since v1.8.0 git://github.com/gitster/git.git

So tags would be allowed as anchors?

Re: [PATCH] git clone depth of 0 not possible.

From: Duy Nguyen <hidden>
Date: 2016-06-15 22:55:41

On Tue, Jan 8, 2013 at 9:32 PM, Stefan Beller
[off-list ref] wrote:
On 01/08/2013 03:28 PM, Duy Nguyen wrote:
quoted
On Tue, Jan 8, 2013 at 2:36 PM, Junio C Hamano [off-list ref] wrote:
quoted
Speaking of --depth, I think in Git 2.0 we should fix the semantics
of "deepening" done with "git fetch".
Speaking of 2.0, we should support depth per ref. Well we don't have
to wait until 2.0 because we could just add shallow2 extension to the
pack protocol. We should also apply depth to new refs when fetching
them the first time.
Would this mean I could do something along?
$ git clone --since v1.8.0 git://github.com/gitster/git.git

So tags would be allowed as anchors?
No. This is what I had in mind:

git clone --branch=master --depth=2 git.git # get branch master with depth 2
git fetch --depth=10 origin next            # get branch next with depth 10
                                            # master's depth remains 2
git fetch origin                # get (new) branch 'pu' with default depth 2

But your case is interesting. We could specify --depth=v1.8.0.. or
even --depth=v1.8.0~200.. (200 commits before v1.8.0). Somebody may
even go crazy and make --depth=v1.6.0..v1.8.0 work. --depth is
probably not the right name anymore. Any SHA-1 would be allowed as
anchor. But I think we need to wait for reachability bitmap feature to
come first so that we can quickly verify the anchor is reachable from
the public refs.
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help