list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <>
To: Jonathan Nieder <>
Cc: Stefan Beller <>,,,
Subject: Re: [PATCH] git clone depth of 0 not possible.
Date: Mon, 07 Jan 2013 23:36:21 -0800	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <> (Junio C. Hamano's message of "Mon, 07 Jan 2013 22:54:20 -0800")

Junio C Hamano <> writes:

> Jonathan Nieder <> writes:
>> Stefan Beller wrote:
>>> 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.



So you do:

    $ git fetch --depth=3


                 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:


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

  reply	other threads:[~2013-01-08  7:36 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-07 18:06 Stefan Beller
2013-01-07 18:06 ` [PATCH] Documentation on depth option in git clone Stefan Beller
2013-01-08  6:28 ` [PATCH] git clone depth of 0 not possible Jonathan Nieder
2013-01-08  6:54   ` Junio C Hamano
2013-01-08  7:36     ` Junio C Hamano [this message]
2013-01-08  8:19       ` Junio C Hamano
2013-01-08 14:28       ` Duy Nguyen
2013-01-08 14:32         ` Stefan Beller
2013-01-08 14:45           ` Duy Nguyen
2013-01-08 17:24           ` Junio C Hamano
2013-01-08  7:38     ` Duy Nguyen
2013-01-08  8:05       ` Junio C Hamano
2013-05-28  9:18         ` Matthijs Kooijman
2013-05-28 16:28           ` Jonathan Nieder
2013-05-28 16:31             ` Jonathan Nieder
2013-05-28 16:34             ` Matthijs Kooijman
2013-05-28 16:58               ` Jonathan Nieder
2013-05-28 17:04           ` Junio C Hamano
2013-05-30  8:23             ` Matthijs Kooijman
2013-06-02 19:14               ` Junio C Hamano
2013-07-09 13:35             ` Matthijs Kooijman
2013-07-11 10:57               ` Matthijs Kooijman
2013-07-11 11:25                 ` [PATCH 1/3] upload-pack: Remove a piece of dead code Matthijs Kooijman
2013-07-11 11:25                   ` [PATCH 2/3] upload-pack: Introduce new "fixed-off-by-one-depth" server feature Matthijs Kooijman
2013-07-11 11:25                   ` [PATCH 3/3] fetch-pack: Request fixed-off-by-one-depth when available Matthijs Kooijman
2013-07-11 12:08                   ` [PATCH 1/3] upload-pack: Remove a piece of dead code Duy Nguyen
2013-07-11 15:49                     ` Junio C Hamano
2013-01-08  7:33 ` [PATCH] git clone depth of 0 not possible Duy Nguyen
2013-01-08  7:37   ` 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:

  List information:

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

  git send-email \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] git clone depth of 0 not possible.' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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

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