{"thread":{"id":"10802","subject":"Dose git-fetch need --reference option like git-clone?","startedAt":"2007-11-11T08:09:55Z","lastAt":"2007-11-11T11:38:37Z","messageCount":5,"participants":["Yin Ping","Junio C Hamano","Mike Hommey"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"59286","messageId":"46dff0320711110009y713c7d38q7b1457c92daecef6@mail.gmail.com","threadId":"10802","inReplyTo":null,"subject":"Dose git-fetch need --reference option like git-clone?","fromName":"Yin Ping","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-11T08:09:55Z","receivedAt":"2007-11-11T08:09:55Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"I want to track remote repsotory (say remoteA) on my local repository\n(say localB), so i do the following in directory localB\n$ git remote add remoteA git://remoteAUrl\n$ git fetch remoteA\nThis will fetch all objects from git://remoteAUrl if localB and\nremoteA don't have common objects.\n\nIf I already have a cloned remoteA on local machine (say\n/path/to/remoteACloned), I want to do following to reduce the net\ntraffic as git-clone:\ngit fetch --reference /path/to/remoteACloned remotedA\n\nIs this reasonable? Or is there already a resolution for this case?\n\n-- \nPing Yin\n"},{"id":"59293","messageId":"7vsl3dgovv.fsf@gitster.siamese.dyndns.org","threadId":"10802","inReplyTo":"46dff0320711110009y713c7d38q7b1457c92daecef6@mail.gmail.com","subject":"Re: Dose git-fetch need --reference option like git-clone?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-11T08:36:20Z","receivedAt":"2007-11-11T08:36:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Yin Ping\" <pkufranky@gmail.com> writes:\n\n> If I already have a cloned remoteA on local machine (say\n> /path/to/remoteACloned), I want to do following to reduce the net\n> traffic as git-clone:\n> git fetch --reference /path/to/remoteACloned remotedA\n>\n> Is this reasonable? Or is there already a resolution for this case?\n\nResolution, meaning \"No, that's not a good thing and we refuse\nto support such an option\"?\n\nNo, there is no such thing.\n\nI think what you are talking about is a reasonable thing to\nwant.  It would have been easier to hack in back when git-fetch\nwas a script, but now you would need to work a bit harder in the\nC code.  On the other hand, however, I suspect the resulting\ncode would be cleaner without having to actually create and\ndelete temporary refs in refs/reference-tmp/ namespace but fake\nthem only in-core, with a proper transport API enhancements.\n\nBut if you only want a quick-and-dirty workaround, you can\nmanually do refs/reference-tmp and objects/info/alternates dance\nthat is done by git-clone before running a git-fetch from such\n\"nearby\" remote.\n\nI strongly suspect that an approach not to use temporary refs on\nthe filesystem would be needed for robustness if we were to do\nthis for real inside git-fetch as a real solution, so that we\nwould not leave them behind when interrupted.  This is not such\na big deal for git-clone which knows it always starts from a\nvoid and cleaning up the mess is not a big issue, but matters\nfor the use of git-fetch under discussion, which _will_ work\ninside an already initialized repository.\n"},{"id":"59294","messageId":"20071111083840.GA17231@glandium.org","threadId":"10802","inReplyTo":"46dff0320711110009y713c7d38q7b1457c92daecef6@mail.gmail.com","subject":"Re: Dose git-fetch need --reference option like git-clone?","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2007-11-11T08:38:40Z","receivedAt":"2007-11-11T08:38:40Z","isPatch":false,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Sun, Nov 11, 2007 at 04:09:55PM +0800, Yin Ping wrote:\n> I want to track remote repsotory (say remoteA) on my local repository\n> (say localB), so i do the following in directory localB\n> $ git remote add remoteA git://remoteAUrl\n> $ git fetch remoteA\n> This will fetch all objects from git://remoteAUrl if localB and\n> remoteA don't have common objects.\n> \n> If I already have a cloned remoteA on local machine (say\n> /path/to/remoteACloned), I want to do following to reduce the net\n> traffic as git-clone:\n> git fetch --reference /path/to/remoteACloned remotedA\n> \n> Is this reasonable? Or is there already a resolution for this case?\n\nIt would probably be reasonable to have this on git-remote. Anyways, you\ncan easily do it yourself by editing .git/objects/info/alternates and\nadding /path/to/remoteACloned in it. You can happily git fetch after\nthat.\n\nMike\n"},{"id":"59301","messageId":"7vfxzdgmvr.fsf@gitster.siamese.dyndns.org","threadId":"10802","inReplyTo":"20071111083840.GA17231@glandium.org","subject":"Re: Dose git-fetch need --reference option like git-clone?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-11T09:19:36Z","receivedAt":"2007-11-11T09:19:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mike Hommey <mh@glandium.org> writes:\n\n> It would probably be reasonable to have this on git-remote. Anyways, you\n> can easily do it yourself by editing .git/objects/info/alternates and\n> adding /path/to/remoteACloned in it. You can happily git fetch after\n> that.\n\nNot really.\n\nThere are two parts in the --reference dance git-clone plays:\n\n - After the reference clone is done, obviously because you are\n   avoiding to actually transfer the data, you need to set up\n   alternates to permanently borrow from the reference\n   repository.\n\n - Because the fetch/clone procedure considers an object that is\n   locally accessible (either it locally exists, or exists in an\n   alternate object store) \"complete\" (meaning, there is no need\n   to fetch the objects that are reachable from it) ONLY when it\n   is reachable from one of the refs in the repository, the\n   above alone would not prevent fetch/clone from actually\n   transferring the objects.  For this reason, git-clone copies\n   the refs that exist in the reference repository as temporary\n   refs.  This ensures that the objects that the clone borrows\n   from the reference repository are considered \"complete\"\n   during the clone process.\n\nThe original design of git differenciated the object store (that\nis, .git/objects/) and a repository (.git).  A repository has an\nobject store associated with it, but the design allowed an\nobject store to be shared among multiple repositories by\nsymlinking.  This is why alternates point at objects/ directory\nof the reference repository, not one level above.\n\nToday, no git tool creates such a \"shared object store\" layout,\nso if the original design were \"an object store belongs only to\none repository, and the ../refs directory relative to it always\nis the only set of refs that defines the completeness of the\nobjects within it.  No sharing of object store across\nrepositories using symlink is allowed\", we could redefine the\ncompleteness rule to also follow the alternates and doing so\nwould eliminate the need for the latter \"temporary ref\" trick\ngit-clone plays.  But until we officially declare that a set of\nold repositories that uses the \"shared object store\" layout are\nnot supported (and give a reasonably migration path), we\nunfortunately cannot do so.\n"},{"id":"59312","messageId":"46dff0320711110338t74d654a3h8811ae9d22f25870@mail.gmail.com","threadId":"10802","inReplyTo":"7vsl3dgovv.fsf@gitster.siamese.dyndns.org","subject":"Re: Dose git-fetch need --reference option like git-clone?","fromName":"Yin Ping","fromEmail":"pkufranky@gmail.com","sentAt":"2007-11-11T11:38:37Z","receivedAt":"2007-11-11T11:38:37Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Nov 11, 2007 4:36 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> No, there is no such thing.\n>\n> I think what you are talking about is a reasonable thing to\n> want.  It would have been easier to hack in back when git-fetch\n> was a script, but now you would need to work a bit harder in the\n> C code.  On the other hand, however, I suspect the resulting\n> code would be cleaner without having to actually create and\n> delete temporary refs in refs/reference-tmp/ namespace but fake\n> them only in-core, with a proper transport API enhancements.\n>\n> But if you only want a quick-and-dirty workaround, you can\n> manually do refs/reference-tmp and objects/info/alternates dance\n> that is done by git-clone before running a git-fetch from such\n> \"nearby\" remote.\n\nNow my workaround is\n$ git remote add remoteA path/to/remoteACloned\n$ git fetch remoteA\nThen update .git/config to let remote.remoteA.url=git://remoteAUrl\n$ git fetch\n\n\n\n\n\n-- \nPing Yin\n"}]}