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

Re: git-clone --single-branch clones objects outside of branch

From
Chris Jerdonek <chris.jerdonek@gmail.com>
Date
Jan 29, 2020, 01:59 UTC
Message-ID
<CAOTb1wecnwXrOqJa-dq1zyS1ydgQ-c_b_GX7FkWzJPtGk6xL3g@mail.gmail.com>
In-Reply-To
<20200128094801.GC574544@coredump.intra.peff.net>
On Tue, Jan 28, 2020 at 1:48 AM Jeff King <peff@peff.net> wrote:
Show 10 quoted lines
> On Sun, Jan 26, 2020 at 10:46:07PM -0800, Chris Jerdonek wrote:
> > I'm guessing other flags also don't apply when --local is being used.
> > For example, I'm guessing --reference is also ignored when using
> > --local, but I haven't checked yet to confirm. It would be nice if the
> > documentation gave a heads up in cases like these. Even if hard links
> > are being used, it's not clear from the docs whether the objects are
> > filtered first, prior to hard linking, when flags like --single-branch
> > and --reference are passed.
>
> No, "--reference" behaves as usual.

On this, I found that --reference does behave differently in the way that I suspected. For example, when run with the default --local, I found that git-clone will create hard links in the new repo to loose objects, even if those objects already exist in the reference repository. When run with --non-local, the objects in the reference repository weren't copied (I didn't find them in the cloned repo's pack file).

So in addition to --single-branch, this seems to be another case where `git-clone --local` will ignore the provided options when deciding what files inside .git/objects/ to hard-link. It just hard-links everything. This is another example of something that I think would be worth mentioning in the docs in some form. Currently, the documentation for --reference suggests that objects won't be created in the new repo if they already exist in the reference repository.

--Chris
Show 6 quoted lines
> However, "--depth" is ignored (and
> issues a warning). I don't think it would be wrong to issue a warning
> when --single-branch is used locally (though it would not be "single
> branch is ignored, since it does impact which refs are copied). But I
> kind of wonder if it would be annoying for people who don't care about
> having the extra objects reachable.
Previous: Jeff KingNext: Jeff King
Message 5 of 6 in “git-clone --single-branch clones objects outside of branch”
  1. Chris JerdonekJan 26, 2020
  2. Jeff KingJan 27, 2020
  3. Chris JerdonekJan 27, 2020
  4. Jeff KingJan 28, 2020
  5. Chris JerdonekJan 29, 2020
  6. Jeff KingJan 29, 2020

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.