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

Re: Re: [PATCH v3] builtin/clone.c: add --reject-shallow option

From
Llilinchao@oschina.cn <lilinchao@oschina.cn>
Date
Feb 20, 2021, 10:40 UTC
Message-ID
<1689e980736811eb80250026b95c99cc@oschina.cn>
In-Reply-To
<eaa219a86bbc11ebb6c7a4badb2c2b1165032@pobox.com>

-------------- lilinchao@oschina.cn

Show 37 quoted lines
>"lilinchao@oschina.cn" <lilinchao@oschina.cn> writes:
>
>> Sorry, you may forget there is a re-read git-config under these lines
>
>Ahhhh, thanks.  You're right that "clone" is "special" in that way
>and requires unusual order---I forgot about that.
>
>>>This is only for cloning from a local repository, no?  IOW, path at
>>>this point may even be "git://github.com/git/git/" and checking with
>>>access() does not make sense.
>>>
>>>Ah, it is even worse.  get_repo_path() can return NULL, so mkpath()
>>>will crash in such a case.  This must be at least
>>>
>>>	if (path && !access(mkpath("%s/shallow", path), F_OK))
>>>	is_shallow = 1;
>>> ...
>>>
>>>So, I think the above two hunks are making the code worse.  If we
>>>are to detect and reject cloning from the shallow repository when
>>>going through the transport layer (i.e. "--no-local" or cloning from
>>>"git://github.com/git/git", or "https://github.com/git/git", if it
>>>were a shallow repository), that must be handled separately.
>>>
>> Sorry, I made the question simple. Reject cloning a shallow repository
>> should apply to all four type transport protocols. There still a bunch of
>> work to be done.
>
>Sorry, but I didn't realize that this is just a work-in-progress
>that shows an early "only local transport is covered" preview.  I
>think, modulo that the access(mkpath()) thing should be in the "if
>(is_local)" block, the patch covers the case of local transport well
>enough.  I think by "four types of transport" you mean ssh://, git://
>https:// etc., but they all go through the same transport API, so
>hopefully once one of them, say, git://, is covered, that would take
>us a long way.
> 
Hi, after some exploration, I found that the following changes
can achieve the goal:
(around at line 1386 in builtin/clone.c)
    /* below part is my changes */
            if (reject_shallow) {
                    if (local_shallow || is_repository_shallow(the_repository)) {
                            die(_("source repository is shallow, reject to clone."));
                    }
            }
    /* end */
            update_remote_refs(refs, mapped_refs, remote_head_points_at,
                               branch_top.buf, reflog_msg.buf, transport,
                               !is_local);

as it shows, using existing method "is_repository_shallow" to detect whether the repo is shallow or not, before "update_remote_refs" I made some tests based on this change, and it seems ok. what do you think about this?

>Thanks.
Previous: Junio C HamanoNext: lilinchao@oschina.cn
Message 44 of 48 in “builtin/clone.c: add --no-shallow option”
  1. builtin/clone.c: add --no-shallow optionLi Linchao via GitGitGadget, Feb 4, 2021
  2. Junio C HamanoFeb 4, 2021
  3. lilinchao@oschina.cnFeb 4, 2021
  4. Junio C HamanoFeb 4, 2021
  5. Johannes SchindelinFeb 4, 2021
  6. Junio C HamanoFeb 4, 2021
  7. 0/2 builtin/clone.c: add --no-shallow optionLi Linchao via GitGitGadget, Feb 8, 2021
  8. 1/2 builtin/clone.c: add --no-shallow optionlilinchao via GitGitGadget, Feb 8, 2021
  9. 2/2 builtin/clone.c: add --reject-shallow optionlilinchao via GitGitGadget, Feb 8, 2021
  10. Derrick StoleeFeb 8, 2021
  11. builtin/clone.c: add --reject-shallow optionLi Linchao via GitGitGadget, Feb 8, 2021
  12. Junio C HamanoFeb 9, 2021
  13. builtin/clone.c: add --reject-shallow optionLi Linchao via GitGitGadget, Feb 21, 2021
  14. Junio C HamanoFeb 22, 2021
  15. Jonathan TanMar 1, 2021
  16. Junio C HamanoMar 1, 2021
  17. lilinchao@oschina.cnMar 2, 2021
  18. Junio C HamanoMar 3, 2021
  19. Jonathan TanMar 4, 2021
  20. builtin/clone.c: add --reject-shallow optionLi Linchao via GitGitGadget, Feb 28, 2021
  21. lilinchao@oschina.cnMar 1, 2021
  22. Johannes SchindelinMar 1, 2021
  23. lilinchao@oschina.cnMar 4, 2021
  24. Junio C HamanoMar 3, 2021
  25. lilinchao@oschina.cnMar 4, 2021
  26. builtin/clone.c: add --reject-shallow optionLi Linchao via GitGitGadget, Mar 4, 2021
  27. lilinchao@oschina.cnMar 12, 2021
  28. builtin/clone.c: add --reject-shallow optionLi Linchao via GitGitGadget, Mar 25, 2021
  29. Junio C HamanoMar 25, 2021
  30. Junio C HamanoMar 25, 2021
  31. builtin/clone.c: add --reject-shallow optionLi Linchao via GitGitGadget, Mar 29, 2021
  32. Junio C HamanoMar 29, 2021
  33. Johannes SchindelinMar 30, 2021
  34. Junio C HamanoMar 30, 2021
  35. Johannes SchindelinMar 31, 2021
  36. builtin/clone.c: add --reject-shallow optionlilinchao via GitGitGadget, Mar 31, 2021
  37. Junio C HamanoMar 31, 2021
  38. Johannes SchindelinMar 31, 2021
  39. Junio C HamanoMar 31, 2021
  40. builtin/clone.c: add --reject-shallow optionLi Linchao via GitGitGadget, Apr 1, 2021
  41. lilinchao@oschina.cnFeb 8, 2021
  42. lilinchao@oschina.cnFeb 10, 2021
  43. Junio C HamanoFeb 10, 2021
  44. lilinchao@oschina.cnFeb 20, 2021
  45. lilinchao@oschina.cnFeb 28, 2021
  46. lilinchao@oschina.cnMar 26, 2021
  47. lilinchao@oschina.cnMar 26, 2021
  48. lilinchao@oschina.cnMar 31, 2021

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.