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

git fetch --depth=* broken?

From
Nicolas Pitre <nico@cam.org>
Date
Aug 22, 2009, 05:52 UTC
Message-ID
<alpine.LFD.2.00.0908220106470.6044@xanadu.home>
try out:
	git clone --depth=1 git://git.kernel.org/pub/scm/git/git
	cd git
	git fetch --depth=2
It then silently fails, except for the return code of 1.
With -v this is the same result.  Only if I remove --depth= do I get:
>From git://git.kernel.org/pub/scm/git/git
 = [up to date]      html       -> origin/html
 = [up to date]      maint      -> origin/maint
 = [up to date]      man        -> origin/man
 = [up to date]      master     -> origin/master
 = [up to date]      next       -> origin/next
 = [up to date]      pu         -> origin/pu
 = [up to date]      todo       -> origin/todo
and a return code of 0.

It seems that commit c6bc400585 is partly responsible for that misbehavior. At least reverting it makes the status list appear again even with the presence of --depth=.

But still, actual result isn't any better. Using --depth=2 or --depth=1000 doesn't change anything, unless there is _also_ a ref that was updated on the remote end. Looks like the code is happy to conclude that there is nothing to do if local refs match remote refs and never go to talk further to the remote end ("no "shallow ..." nor "deepen ..." are sent over the wire) despite the fact that --depth=1000 would certainly have to trigger a pack transfer.

I'm also surprised that such thing as simple deepening of a repo is not in the test suite. We certainly document this operation in the git-fetch man page though.

The code in builtin-fetch-pack.c still looks rather confusing to me, so hopefully you are more familiar with it and can provide a fix.

Nicolas
Next: Nicolas Pitre
Message 1 of 22 in “git fetch --depth=* broken?”
  1. Nicolas PitreAug 22, 2009
  2. fix simple deepening of a repoNicolas Pitre, Aug 24, 2009
  3. Junio C HamanoAug 24, 2009
  4. Nicolas PitreAug 24, 2009
  5. Johan HerlandAug 24, 2009
  6. Junio C HamanoAug 24, 2009
  7. Daniel BarkalowAug 24, 2009
  8. Julian PhillipsAug 24, 2009
  9. Nicolas PitreAug 25, 2009
  10. Shawn O. PearceAug 25, 2009
  11. Sverre RabbelierAug 25, 2009
  12. Junio C HamanoAug 25, 2009
  13. Shawn O. PearceAug 25, 2009
  14. Junio C HamanoAug 25, 2009
  15. Shawn O. PearceAug 25, 2009
  16. Shawn O. PearceAug 26, 2009
  17. Johannes SixtAug 26, 2009
  18. Shawn O. PearceAug 26, 2009
  19. Junio C HamanoAug 26, 2009
  20. Shawn O. PearceAug 26, 2009
  21. upload-pack: expand capability advertises additional refsShawn O. Pearce, Aug 28, 2009
  22. Junio C HamanoAug 28, 2009

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.