git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Matthijs Kooijman <matthijs@stdin.nl>
Date
Jul 11, 2013, 10:57 UTC
Message-ID
<20130711105733.GG10217@login.drsnuggles.stderr.nl>
In-Reply-To
<20130709133542.GJ10217@login.drsnuggles.stderr.nl>
Hi Junio,
Show 26 quoted lines
> While implementing the above, I noticed my fix now introduced an
> off-by-one error the other way. When investigating, I found this commit:
> 
> 	commit 682c7d2f1a2d1a5443777237450505738af2ff1a
> 	Author: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> 	Date:   Fri Jan 11 16:05:47 2013 +0700
> 
> 	    upload-pack: fix off-by-one depth calculation in shallow clone
> 
> 	    get_shallow_commits() is used to determine the cut points at a given
> 	    depth (i.e. the number of commits in a chain that the user likes to
> 	    get). However we count current depth up to the commit "commit" but we
> 	    do the cutting at its parents (i.e. current depth + 1). This makes
> 	    upload-pack always return one commit more than requested. This patch
> 	    fixes it.
> 
> 	    Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> 	    Signed-off-by: Junio C Hamano <gitster@pobox.com>
> 
> Which actually seems to fix the off-by-one bug that is described in this
> thread, but without going through the hoops of preserving current
> behaviour for older git versions (that is, it makes behaviour dependent
> on server version instead of client version).
> 
> Does this mean the discussion in this thread is meaningless, or is that
> commit not intended to be the final fix?

Looking more closely, I also see that the above change is already released in 1.8.2 versions. Given that, I don't think it makes sense to to still try to provide this capability to get backward compatible behaviour, since this would cause a off-by-one error the other way when talking to 1.8.2.x servers...

However, since I pretty much finished the code for this, I'll send over the patches and let you decide wether to include them or not. If you want to include them but they need to be changed in some way, just let me know.

The first patch of the series should be merged regardless.
Gr.
Matthijs
Previous: Matthijs KooijmanNext: Matthijs Kooijman
Message 22 of 29 in “git clone depth of 0 not possible.”
  1. git clone depth of 0 not possible.Stefan Beller, Jan 7, 2013
  2. Documentation on depth option in git clone.Stefan Beller, Jan 7, 2013
  3. Jonathan NiederJan 8, 2013
  4. Junio C HamanoJan 8, 2013
  5. Junio C HamanoJan 8, 2013
  6. Junio C HamanoJan 8, 2013
  7. Duy NguyenJan 8, 2013
  8. Stefan BellerJan 8, 2013
  9. Duy NguyenJan 8, 2013
  10. Junio C HamanoJan 8, 2013
  11. Duy NguyenJan 8, 2013
  12. Junio C HamanoJan 8, 2013
  13. Matthijs KooijmanMay 28, 2013
  14. Jonathan NiederMay 28, 2013
  15. Jonathan NiederMay 28, 2013
  16. Matthijs KooijmanMay 28, 2013
  17. Jonathan NiederMay 28, 2013
  18. Junio C HamanoMay 28, 2013
  19. Matthijs KooijmanMay 30, 2013
  20. Junio C HamanoJun 2, 2013
  21. Matthijs KooijmanJul 9, 2013
  22. Matthijs KooijmanJul 11, 2013
  23. 1/3 upload-pack: Remove a piece of dead codeMatthijs Kooijman, Jul 11, 2013
  24. 2/3 upload-pack: Introduce new "fixed-off-by-one-depth" server featureMatthijs Kooijman, Jul 11, 2013
  25. 3/3 fetch-pack: Request fixed-off-by-one-depth when availableMatthijs Kooijman, Jul 11, 2013
  26. Duy NguyenJul 11, 2013
  27. Junio C HamanoJul 11, 2013
  28. Duy NguyenJan 8, 2013
  29. Junio C HamanoJan 8, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.