{"thread":{"id":"1773","subject":"Re: What's up with the GIT archive on www.kernel.org?","startedAt":"2005-09-11T19:06:44Z","lastAt":"2005-09-13T17:30:13Z","messageCount":18,"participants":["Linus Torvalds","Sam Ravnborg","Junio C Hamano","Roland Dreier","Dmitry Torokhov","H. Peter Anvin","Tony Luck","Ryan Anderson","Daniel Barkalow"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"8317","messageId":"Pine.LNX.4.58.0509111157360.3242@g5.osdl.org","threadId":"1773","inReplyTo":"20050911185711.GA22556@mars.ravnborg.org","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-09-11T19:06:44Z","receivedAt":"2005-09-11T19:06:44Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 11 Sep 2005, Sam Ravnborg wrote:\n> > \n> > Absolutely. The mirroring has been slow again lately. I've packed my \n> > archive, but I suspect others should much more aggressively now be using \n> > the \"objects/info/alternates\" information to point to my tree, so that \n> > they don't even need to have their objects at all (no packing \n> > even necessary - just running \"git prune-packed\" on peoples archives \n> > would get rid of any duplicate objects when I pack mine).\n> \n> Can you post a small description how to utilize this method?\n\nJust do\n\n\techo /pub/scm/linux/kernel/git/torvalds/linux-2.6.git/objects > objects/info/alternates\n\nin your tree, and that will tell git that your tree can use my object \ndirectory as an \"alternate\" source of objects. At that point, you can \nremove all objects that I have.\n\nHowever, that only works with a local directory - you can't say that the\nalternate object directory is over the network (unless you use NFS or\nsimilar, of course ;).\n\nAnother potential problem is that while the above makes git understand to\npick the objects from my directory, it can in theory cause problems for\nmirrors etc - since they mirror things to a different location and/or may\nnot mirror all of it anyway.\n\nAnyway, modulo those caveats, you can then just do\n\n\tgit prune-packed\n\nand it will remove all unpacked objects in your git archive that can be \nreached through a pack-file - including any packfiles in _my_ directory. \n\nThen you never need to pack your own objects any more. Just leave\neverything unpacked, and rely on me packing every once in a while, and\njust do \"git prune-packed\" when I do.\n\nThat allows a site like kernel.org to effectively share 99% of all \nobjects, and do it efficiently.\n\n\t\tLinus\n"},{"id":"8318","messageId":"20050911194630.GB22951@mars.ravnborg.org","threadId":"1773","inReplyTo":"Pine.LNX.4.58.0509111157360.3242@g5.osdl.org","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Sam Ravnborg","fromEmail":"sam@ravnborg.org","sentAt":"2005-09-11T19:46:30Z","receivedAt":"2005-09-11T19:46:30Z","isPatch":false,"sender":{"key":"sam@ravnborg.org","avatar":"https://gravatar.com/avatar/168a912606ed0742d840bb365e3cc21db390c36531a58341dc7a069cc1f15f62?d=mp&s=160"},"body":"> > \n> > Can you post a small description how to utilize this method?\n> \n> Just do\n> \n> \techo /pub/scm/linux/kernel/git/torvalds/linux-2.6.git/objects > objects/info/alternates\n> \n> in your tree, and that will tell git that your tree can use my object \n> directory as an \"alternate\" source of objects. At that point, you can \n> remove all objects that I have.\n\nOK - what I did:\n\ncd /pub/scm/linux/kernel/git/sam\nrm -rf kbuild.git\ngit clone /pub/scm/linux/kernel/git/torvalds/linux-2.6.git kbuild.git\nrename to .git to kbuild.git\n\nI had to specify both GIT_DIR and GIT_OBJECT_DIRECTORY to make\ngit-prune-packed behave as expected. I assume this is normal when I\nrename the .git directory like in this case.\n\nI will se if any pullers complins (mostly/only Andrew I think).\n\n\tSam\n"},{"id":"8319","messageId":"Pine.LNX.4.58.0509111251150.3242@g5.osdl.org","threadId":"1773","inReplyTo":"20050911194630.GB22951@mars.ravnborg.org","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-09-11T19:56:12Z","receivedAt":"2005-09-11T19:56:12Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 11 Sep 2005, Sam Ravnborg wrote:\n> \n> I had to specify both GIT_DIR and GIT_OBJECT_DIRECTORY to make\n> git-prune-packed behave as expected. I assume this is normal when I\n> rename the .git directory like in this case.\n\nYou should only need to specify GIT_DIR - it should figure out that the \nobject directory follows GIT_DIR on its own.\n\nAlso, I forget what version of git is installed on kernel.org. The\n\"alternates\" support has been around for a while, and looking at the date\nof \"/usr/bin/git\" it _seems_ recent (Sep 7), but I haven't seen any\nannouncement of updating since the last one (which was git-0.99.4, which\nis too old).\n\nYou can try removing all the packs in your .git/objects/packs directory. \nEverything _should_ still work fine.\n\nFamous last words.\n\n\t\tLinus\n"},{"id":"8320","messageId":"7v64t7s6zc.fsf@assigned-by-dhcp.cox.net","threadId":"1773","inReplyTo":"Pine.LNX.4.58.0509111157360.3242@g5.osdl.org","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-11T20:08:07Z","receivedAt":"2005-09-11T20:08:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> On Sun, 11 Sep 2005, Sam Ravnborg wrote:\n>> > \n>> > Absolutely. The mirroring has been slow again lately. I've packed my \n>> > archive, but I suspect others should much more aggressively now be using \n>> > the \"objects/info/alternates\" information to point to my tree, so that \n>> > they don't even need to have their objects at all (no packing \n>> > even necessary - just running \"git prune-packed\" on peoples archives \n>> > would get rid of any duplicate objects when I pack mine).\n>> \n>> Can you post a small description how to utilize this method?\n>\n> Just do\n>\n> \techo /pub/scm/linux/kernel/git/torvalds/linux-2.6.git/objects > objects/info/alternates\n>\n> in your tree, and that will tell git that your tree can use my object \n> directory as an \"alternate\" source of objects. At that point, you can \n> remove all objects that I have.\n>\n> However, that only works with a local directory - you can't say that the\n> alternate object directory is over the network (unless you use NFS or\n> similar, of course ;).\n>\n> Another potential problem is that while the above makes git understand to\n> pick the objects from my directory, it can in theory cause problems for\n> mirrors etc - since they mirror things to a different location and/or may\n> not mirror all of it anyway.\n\nAnd probably it would break fetching over dumb transports.\n"},{"id":"8326","messageId":"52irx7cnw5.fsf@cisco.com","threadId":"1773","inReplyTo":"Pine.LNX.4.58.0509111251150.3242@g5.osdl.org","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Roland Dreier","fromEmail":"rolandd@cisco.com","sentAt":"2005-09-11T21:09:30Z","receivedAt":"2005-09-11T21:09:30Z","isPatch":false,"sender":{"key":"rolandd@cisco.com","avatar":null},"body":"    Linus> You can try removing all the packs in your\n    Linus> .git/objects/packs directory. Everything _should_ still\n    Linus> work fine.\n\nDoes \"everything\" include someone doing\n\n    git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/roland/whatever.git\n\nHow about http:// instead of rsync://?\n\nIn other words, is the git network transport smart enough to handle\nthe alternates path?\n\nOr is the idea that everyone will clone your tree and then pull extra\nstuff from other trees?\n\n - R.\n"},{"id":"8329","messageId":"Pine.LNX.4.58.0509111422510.3242@g5.osdl.org","threadId":"1773","inReplyTo":"52irx7cnw5.fsf@cisco.com","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-09-11T21:24:48Z","receivedAt":"2005-09-11T21:24:48Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 11 Sep 2005, Roland Dreier wrote:\n> \n> Does \"everything\" include someone doing\n> \n>     git clone rsync://rsync.kernel.org/pub/scm/linux/kernel/git/roland/whatever.git\n\nNope. Only server-side smart protocols will handle this.\n\nThere is such an anonymous server, btw: \"git-daemon\" implements anonymous \naccess much more efficient than rsync/http. Sadly, kernel.org still \ndoesn't offer it (but it's now used in the wild, ie I've done a couple of \nmerges with people running the git daemon).\n\n> In other words, is the git network transport smart enough to handle\n> the alternates path?\n\nThe _git_ network transport is. rsync and http aren't.\n\n\t\tLinus\n"},{"id":"8330","messageId":"Pine.LNX.4.58.0509111431400.3242@g5.osdl.org","threadId":"1773","inReplyTo":"Pine.LNX.4.58.0509111422510.3242@g5.osdl.org","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-09-11T21:33:19Z","receivedAt":"2005-09-11T21:33:19Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 11 Sep 2005, Linus Torvalds wrote:\n> \n> The _git_ network transport is. rsync and http aren't.\n\nBtw, there's no reason why a client-side thing couldn't just parse the \n\"alternates\" thing, and if it doesn't find the objects in the main object \ndirectory, go and fetch them from the alternates itself.\n\nIOW, this is not a fundamental problem with alternates, it's just that\nsince there is no server-side smarts to handle it (ie just raw file access\nwith rsync/http), it needs to be handled at the client side instead.\n\n\t\tLinus\n"},{"id":"8355","messageId":"7virx7njxa.fsf@assigned-by-dhcp.cox.net","threadId":"1773","inReplyTo":"Pine.LNX.4.58.0509111431400.3242@g5.osdl.org","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-12T01:39:45Z","receivedAt":"2005-09-12T01:39:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> Btw, there's no reason why a client-side thing couldn't just parse the \n> \"alternates\" thing, and if it doesn't find the objects in the main object \n> directory, go and fetch them from the alternates itself.\n\nThere is.\n\nFor kernel.org, you could say '/pub/scm/blah' in your alternates\nand expect it to work, only because http://kernel.org/pub\nhierarchy happens to match the absolute path /pub on the\nfilesystem, but for most people's default HTTP server\ninstallation, they would need to say /var/www/scm/blah to have\nalternate work locally, but somebody has to know that the named\ndirectory is served as http://machine.xz/pub/scm/blah somewhere.\n\nClient side smarts need some help from the user here to know\nthat '/var/www/scm/blah' read off of objects/info/alternates\nmatch that URL.\n"},{"id":"8359","messageId":"200509112145.33994.dtor_core@ameritech.net","threadId":"1773","inReplyTo":"7virx7njxa.fsf@assigned-by-dhcp.cox.net","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Dmitry Torokhov","fromEmail":"dtor_core@ameritech.net","sentAt":"2005-09-12T02:45:33Z","receivedAt":"2005-09-12T02:45:33Z","isPatch":false,"sender":{"key":"dtor_core@ameritech.net","avatar":null},"body":"On Sunday 11 September 2005 20:39, Junio C Hamano wrote:\n> Linus Torvalds <torvalds@osdl.org> writes:\n> \n> > Btw, there's no reason why a client-side thing couldn't just parse the \n> > \"alternates\" thing, and if it doesn't find the objects in the main object \n> > directory, go and fetch them from the alternates itself.\n> \n> There is.\n> \n> For kernel.org, you could say '/pub/scm/blah' in your alternates\n> and expect it to work, only because http://kernel.org/pub\n> hierarchy happens to match the absolute path /pub on the\n> filesystem, but for most people's default HTTP server\n> installation, they would need to say /var/www/scm/blah to have\n> alternate work locally, but somebody has to know that the named\n> directory is served as http://machine.xz/pub/scm/blah somewhere.\n> \n\nCall me brain-dead but all of this just makes me rsync my tree to\nkernel.org and then manually do \"ln -f\" for all the packs that Linus\nhas. This way I am sure tht the tree is what I have plus and it is\n\"pullable\".\n\n\n-- \nDmitry\n"},{"id":"8360","messageId":"Pine.LNX.4.58.0509112038020.3242@g5.osdl.org","threadId":"1773","inReplyTo":"7virx7njxa.fsf@assigned-by-dhcp.cox.net","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-09-12T03:39:46Z","receivedAt":"2005-09-12T03:39:46Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 11 Sep 2005, Junio C Hamano wrote:\n> \n> For kernel.org, you could say '/pub/scm/blah' in your alternates\n> and expect it to work, only because http://kernel.org/pub\n> hierarchy happens to match the absolute path /pub on the\n> filesystem, but for most people's default HTTP server\n> installation, they would need to say /var/www/scm/blah to have\n> alternate work locally, but somebody has to know that the named\n> directory is served as http://machine.xz/pub/scm/blah somewhere.\n\nYes. We should probably have some well-defined meaning for relative paths\nin there regardless (eg just define that they are always relative to the\nmain GIT_OBJECT_DIRECTORY or something).\n\nThat would also allow mirrors to mirror the git archives in different \nplaces, without upsetting the result (as long as they are mirrored \ntogether).\n\n\t\tLinus\n"},{"id":"8403","messageId":"4325B698.1050805@zytor.com","threadId":"1773","inReplyTo":"7virx7njxa.fsf@assigned-by-dhcp.cox.net","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-09-12T17:10:48Z","receivedAt":"2005-09-12T17:10:48Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Junio C Hamano wrote:\n> \n> For kernel.org, you could say '/pub/scm/blah' in your alternates\n> and expect it to work, only because http://kernel.org/pub\n> hierarchy happens to match the absolute path /pub on the\n> filesystem...\n >\n\nActually it doesn't.  /pub in the root directory on kernel.org is just a \nconvenience symlink.\n\n\t-hpa\n"},{"id":"8406","messageId":"12c511ca050912112266470d8b@mail.gmail.com","threadId":"1773","inReplyTo":"Pine.LNX.4.58.0509111422510.3242@g5.osdl.org","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Tony Luck","fromEmail":"tony.luck@gmail.com","sentAt":"2005-09-12T18:22:58Z","receivedAt":"2005-09-12T18:22:58Z","isPatch":false,"sender":{"key":"tony.luck@gmail.com","avatar":null},"body":"On 9/11/05, Linus Torvalds <torvalds@osdl.org> wrote:\n> There is such an anonymous server, btw: \"git-daemon\" implements anonymous\n> access much more efficient than rsync/http. Sadly, kernel.org still\n> doesn't offer it (but it's now used in the wild, ie I've done a couple of\n> merges with people running the git daemon).\n\nShould the git daemon take a look at objects/info/alternates to check\nthat if it exists, it\npoints to a repository that also has a \"git-daemon-export-ok\" file?  \nI don't see that this\ncould be used for anything nasty, but it does provide a loophole where\nthe daemon may\nopen files outside the initial repository ... so a sanity check seems in order.\n\n-Tony\n"},{"id":"8409","messageId":"Pine.LNX.4.58.0509121128170.3242@g5.osdl.org","threadId":"1773","inReplyTo":"12c511ca050912112266470d8b@mail.gmail.com","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-09-12T18:37:13Z","receivedAt":"2005-09-12T18:37:13Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Mon, 12 Sep 2005, Tony Luck wrote:\n> \n> Should the git daemon take a look at objects/info/alternates to check\n> that if it exists, it points to a repository that also has a\n> \"git-daemon-export-ok\" file?\n\nI considered it, but decided against the complexity. I just don't see the \npoint. The \"git-daemon-export-ok\" is not so much about security as about \n_accidental_ exposure. \n\nRemember: the security is in the writing. If you allow \"bad people\" enough\ncapabilities that they can create their own git archive and can read the\ntarget archive, those \"bad people\" could just export the target archive\nsome other way in the first place (ie they could have just copied the\nfiles over to their own area).\n\nAnd there are actually real downsides to requiring \"git-daemon-export-ok\" \nfrom a security standpoint. In particular, imagine that a company has a \n\"master archive\", and wants to export just a particular \"public branch\" \nfrom that master archive. The way you can do that right now is to create a \ndummy git archive, that is empty except for having one head (symlink to \nthe public branch head in the master) and an \"alternates\" pointer to the \nmaster.\n\nSee? You don't actually want to expose the master archive itself: so \nrequiring that one to also have \"git-daemon-export-ok\" would actually \n_defeat_ the security in the system. \n\nSo the git approach to security is that you secure the writing side.  \nThat's where you use ssh. And even if you happen to run git-daemon, it\nwill never export anything that you didn't explicitly mark for export, so\nit defaults to a \"nothing exported\" mode. But once you mark a project for\npublic export, the branches exposed there really are public.\n\n(And the branches _not_ exposed there are private. Sure, if you can guess\nthe SHA1 ID's, you can make git-daemon export them, but the point is that\ngit-daemon will never expose any SHA1's from other projects unless they\nhave the \"git-daemon-export-ok\" flag set. And the thing is, if you know\nthe SHA1's, you already know the contents and you had a leak some other\nway, so..).\n\n\t\t\tLinus\n"},{"id":"8410","messageId":"20050912184214.GB5276@mythryan2.michonline.com","threadId":"1773","inReplyTo":"200509112145.33994.dtor_core@ameritech.net","subject":"Re: What's up with the GIT archive on www.kernel.org?","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2005-09-12T18:42:14Z","receivedAt":"2005-09-12T18:42:14Z","isPatch":false,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"On Sun, Sep 11, 2005 at 09:45:33PM -0500, Dmitry Torokhov wrote:\n> \n> Call me brain-dead but all of this just makes me rsync my tree to\n> kernel.org and then manually do \"ln -f\" for all the packs that Linus\n> has. This way I am sure tht the tree is what I have plus and it is\n> \"pullable\".\n\nIf you have access to make hardlinks, you should be able to use\ngit-relink to do the hard work for you.\n\n>From memory:\n\tgit relink my_dir1 my_dir2 ... master_dir\n\nor:\n\tgit relink my-kernel-tree /pub/scm/.../torvalds/linux.git/\n\n(I think that will work - via a bug in my initial attempt to write\ngit-relink, I look to make sure the path ends in \".git/\" not \"/.git/\".\nSo the above should work.  I think.)\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n"},{"id":"8456","messageId":"7vk6hl4fd9.fsf_-_@assigned-by-dhcp.cox.net","threadId":"1773","inReplyTo":"Pine.LNX.4.58.0509112038020.3242@g5.osdl.org","subject":"[PATCH] Define relative .git/objects/info/alternates semantics.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-13T07:05:22Z","receivedAt":"2005-09-13T07:05:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> Yes. We should probably have some well-defined meaning for relative paths\n> in there regardless (eg just define that they are always relative to the\n> main GIT_OBJECT_DIRECTORY or something).\n>\n> That would also allow mirrors to mirror the git archives in different \n> places, without upsetting the result (as long as they are mirrored \n> together).\n>\n> \t\tLinus\n\nThis patch is request-for-comments.  I have experimented it and\nhave a feeling that it may be more intuitive to make it relative\nto $project.git/ directory, instead of $project.git/objects as\nyou originally suggested, in which case a maintainer tree would\nhave \"../../torvalds/linux-2.6.git/objects\" instead (one less\ndotdot), and if nobody objects that is probably what I'll end up\ndoing.\n\n------------\nAn entry in the alternates file can name a directory relative to\nthe object store it describes.  A typical linux-2.6 maintainer\nrepository would have \"../../../torvalds/linux-2.6.git/objects\" there,\nbecause the subsystem maintainer object store would live in\n\n    /pub/scm/linux/kernel/git/$u/$system.git/objects/\n\nand the object store of Linus tree is in\n\n    /pub/scm/linux/kernel/git/torvalds/linux-2.6.git/objects/\n\nThis unfortunately is different from GIT_ALTERNATE_OBJECT_DIRECTORIES\nwhich is relative to the cwd of the running process, but there is no\nway to make it consistent with the behaviour of the environment\nvariable.  The process typically is run in $system.git/ directory for\na naked repository, or one level up for a repository with a working\ntree, so we just define it to be relative to the objects/ directory\nto be different from either ;-).\n\nLater, the dumb transport could be updated to read from info/alternates\nand make requests for the repository the repository borrows from.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n sha1_file.c |   28 ++++++++++++++++++++++------\n 1 files changed, 22 insertions(+), 6 deletions(-)\n\ne2e8a0ba5fc80368bf46c615276e406dd373729c\ndiff --git a/sha1_file.c b/sha1_file.c\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -240,10 +240,12 @@ static struct alternate_object_database \n  * SHA1, an extra slash for the first level indirection, and the\n  * terminating NUL.\n  */\n-static void link_alt_odb_entries(const char *alt, const char *ep, int sep)\n+static void link_alt_odb_entries(const char *alt, const char *ep, int sep,\n+\t\t\t\t const char *relative_base)\n {\n \tconst char *cp, *last;\n \tstruct alternate_object_database *ent;\n+\tint base_len = -1;\n \n \tlast = alt;\n \twhile (last < ep) {\n@@ -261,12 +263,25 @@ static void link_alt_odb_entries(const c\n \t\t\tint pfxlen = cp - last;\n \t\t\tint entlen = pfxlen + 43;\n \n+\t\t\tif (*last != '/' && relative_base) {\n+\t\t\t\t/* Relative alt-odb */\n+\t\t\t\tif (base_len < 0)\n+\t\t\t\t\tbase_len = strlen(relative_base) + 1;\n+\t\t\t\tentlen += base_len;\n+\t\t\t\tpfxlen += base_len;\n+\t\t\t}\n \t\t\tent = xmalloc(sizeof(*ent) + entlen);\n \t\t\t*alt_odb_tail = ent;\n \t\t\talt_odb_tail = &(ent->next);\n \t\t\tent->next = NULL;\n-\n-\t\t\tmemcpy(ent->base, last, pfxlen);\n+\t\t\tif (*last != '/' && relative_base) {\n+\t\t\t\tmemcpy(ent->base, relative_base, base_len - 1);\n+\t\t\t\tent->base[base_len - 1] = '/';\n+\t\t\t\tmemcpy(ent->base + base_len,\n+\t\t\t\t       last, cp - last);\n+\t\t\t}\n+\t\t\telse\n+\t\t\t\tmemcpy(ent->base, last, pfxlen);\n \t\t\tent->name = ent->base + pfxlen + 1;\n \t\t\tent->base[pfxlen] = ent->base[pfxlen + 3] = '/';\n \t\t\tent->base[entlen-1] = 0;\n@@ -288,12 +303,12 @@ void prepare_alt_odb(void)\n \talt = getenv(ALTERNATE_DB_ENVIRONMENT);\n \tif (!alt) alt = \"\";\n \n-\tsprintf(path, \"%s/info/alternates\", get_object_directory());\n \tif (alt_odb_tail)\n \t\treturn;\n \talt_odb_tail = &alt_odb_list;\n-\tlink_alt_odb_entries(alt, alt + strlen(alt), ':');\n+\tlink_alt_odb_entries(alt, alt + strlen(alt), ':', NULL);\n \n+\tsprintf(path, \"%s/info/alternates\", get_object_directory());\n \tfd = open(path, O_RDONLY);\n \tif (fd < 0)\n \t\treturn;\n@@ -306,7 +321,8 @@ void prepare_alt_odb(void)\n \tif (map == MAP_FAILED)\n \t\treturn;\n \n-\tlink_alt_odb_entries(map, map + st.st_size, '\\n');\n+\tlink_alt_odb_entries(map, map + st.st_size, '\\n',\n+\t\t\t     get_object_directory());\n \tmunmap(map, st.st_size);\n }\n \n"},{"id":"8466","messageId":"Pine.LNX.4.58.0509130918170.3351@g5.osdl.org","threadId":"1773","inReplyTo":"7vk6hl4fd9.fsf_-_@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Define relative .git/objects/info/alternates semantics.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-09-13T16:22:42Z","receivedAt":"2005-09-13T16:22:42Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 13 Sep 2005, Junio C Hamano wrote:\n>\n> This patch is request-for-comments.  I have experimented it and\n> have a feeling that it may be more intuitive to make it relative\n> to $project.git/ directory, instead of $project.git/objects as\n> you originally suggested\n\nI don't think you can do that.\n\nI always felt that \"alternates\" should be per-project, but you're the one \nwho argued that \"alternates\" is a per-object-directory thing.\n\nWhich means that the _same_ \"alternates\" file can be shared with many\ndifferent project.git/ directories, and thus it's not well-defined to make\nit relative to GIT_DIR.\n\nYou can make it relative to \"GIT_OBJECTS_DIR/..\" of course, which in most\ncases is the same thing as \"GIT_DIR\".\n\n\t\tLinus\n"},{"id":"8467","messageId":"Pine.LNX.4.63.0509131224290.23242@iabervon.org","threadId":"1773","inReplyTo":"7vk6hl4fd9.fsf_-_@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Define relative .git/objects/info/alternates semantics.","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2005-09-13T16:31:38Z","receivedAt":"2005-09-13T16:31:38Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Tue, 13 Sep 2005, Junio C Hamano wrote:\n\n> Linus Torvalds <torvalds@osdl.org> writes:\n> \n> > Yes. We should probably have some well-defined meaning for relative paths\n> > in there regardless (eg just define that they are always relative to the\n> > main GIT_OBJECT_DIRECTORY or something).\n> >\n> > That would also allow mirrors to mirror the git archives in different \n> > places, without upsetting the result (as long as they are mirrored \n> > together).\n> >\n> > \t\tLinus\n> \n> This patch is request-for-comments.  I have experimented it and\n> have a feeling that it may be more intuitive to make it relative\n> to $project.git/ directory, instead of $project.git/objects as\n> you originally suggested, in which case a maintainer tree would\n> have \"../../torvalds/linux-2.6.git/objects\" instead (one less\n> dotdot), and if nobody objects that is probably what I'll end up\n> doing.\n\nIt seems odd to have the \"objects\" at the end and not be starting from \n\"objects\". I suspect that the most intuitive thing would be for something \nunder $project.git/info to be .git to .git, while something under \n.git/objects/info should be objects to objects.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"8468","messageId":"7vvf143mfu.fsf@assigned-by-dhcp.cox.net","threadId":"1773","inReplyTo":"Pine.LNX.4.58.0509130918170.3351@g5.osdl.org","subject":"Re: [PATCH] Define relative .git/objects/info/alternates semantics.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-09-13T17:30:13Z","receivedAt":"2005-09-13T17:30:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> Which means that the _same_ \"alternates\" file can be shared with many\n> different project.git/ directories, and thus it's not well-defined to make\n> it relative to GIT_DIR.\n\nGood point.\n\n> You can make it relative to \"GIT_OBJECTS_DIR/..\" of course, which in most\n> cases is the same thing as \"GIT_DIR\".\n\nAgain, good point.\n"}]}