{"thread":{"id":"27975","subject":"help: the question about relative path in the objects/info/alternates","startedAt":"2011-08-01T09:16:56Z","lastAt":"2011-08-02T07:15:56Z","messageCount":3,"participants":["Jason Wang","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"172514","messageId":"4E366F08.2060808@gmail.com","threadId":"27975","inReplyTo":null,"subject":"help: the question about relative path in the objects/info/alternates","fromName":"Jason Wang","fromEmail":"jason77.wang@gmail.com","sentAt":"2011-08-01T09:16:56Z","receivedAt":"2011-08-01T09:16:56Z","isPatch":false,"sender":{"key":"jason77.wang@gmail.com","avatar":null},"body":"Hi git experts,\n\n From the objects/info/alternates part of this URL \nhttp://www.kernel.org/pub/software/scm/git/docs/gitrepository-layout.html, \nit says it will work if alternates has relative path in it. But i found \nit will always fail under below situation, i don't know whether the \nfailure is due to the git nature or it is a git potential bug.\n\nThe failure situation is like that:\nOn my machine, i have a git bare base repository, e.g. \n/home/jason/source/base-bare. On the same machine, i have a git bare \nincremental (it need to refer to base repository) repository, e.g. \n/home/jason/source/incremental-bare. In the \nincremental-bare/objects/info/alternates, i set a relative path to point \nto the objects of base-bare like this \"../../base-bare/objects\". Then i \nwant to clone a new repository from the incremental-bare on the same \nmachine, if i use this command \"git clone \n/home/jason/source/incremental-bare new-project\", it will fail; but if i \nuse this command \"git clone file:///home/jason/source/incremental-bare \nnew-project\", it will work successfully, Why the first one can't work, \nit is a bug for git?\n\nIn addtion, if i write an absolute path in the \nincremental-bare/objects/info/alternates like this \n\"/home/jason/source/base-bare/objects\", it will always work well no \nmatter i add or don't add \"file://\".\n\nThanks\nJason Wang.\n"},{"id":"172549","messageId":"7vr555hvqf.fsf@alter.siamese.dyndns.org","threadId":"27975","inReplyTo":"4E366F08.2060808@gmail.com","subject":"Re: help: the question about relative path in the objects/info/alternates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-01T17:44:56Z","receivedAt":"2011-08-01T17:44:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jason Wang <jason77.wang@gmail.com> writes:\n\n> From the objects/info/alternates part of this URL\n> http://www.kernel.org/pub/software/scm/git/docs/gitrepository-layout.html,\n> it says it will work if alternates has relative path in it.\n\nIt does not just say \"relative path\", but \"relative to the object\ndatabase\".  It expresses where the \"objects\" directory you are borrowing\nfrom is, relative to your own \"objects\" directory.\n\nFor example, if you have /src/ib/{objects,refs,HEAD} as your repository\nthat borrows from elsewhere, say /src/base/, then objects/info/alternates\nfile in the borrowing repository should say either /src/base/objects/, or\n\"../../base/objects\".\n\nAn easy way to make sure you do not make typo is to go to your borrowing\nobjects directory, and then let your shell completion to type your path,\nlike this:\n\n    $ cd /home/jason/source/incremental-bare\n    $ cd objects\n    $ echo ../../base-bare/objects >info/alternates\n\nWhile formulating that \"echo\" command line, you would type ../../ <TAB>\nand pick base-bare, <TAB> and pick objects.\n"},{"id":"172634","messageId":"4E37A42C.3070702@gmail.com","threadId":"27975","inReplyTo":"7vr555hvqf.fsf@alter.siamese.dyndns.org","subject":"Re: help: the question about relative path in the objects/info/alternates","fromName":"Jason Wang","fromEmail":"jason77.wang@gmail.com","sentAt":"2011-08-02T07:15:56Z","receivedAt":"2011-08-02T07:15:56Z","isPatch":false,"sender":{"key":"jason77.wang@gmail.com","avatar":null},"body":"Junio C Hamano wrote:\n> Jason Wang <jason77.wang@gmail.com> writes:\n>\n>   \n>> From the objects/info/alternates part of this URL\n>> http://www.kernel.org/pub/software/scm/git/docs/gitrepository-layout.html,\n>> it says it will work if alternates has relative path in it.\n>>     \n>\n> It does not just say \"relative path\", but \"relative to the object\n> database\".  It expresses where the \"objects\" directory you are borrowing\n> from is, relative to your own \"objects\" directory.\n>   \nUnderstand.\n> For example, if you have /src/ib/{objects,refs,HEAD} as your repository\n> that borrows from elsewhere, say /src/base/, then objects/info/alternates\n> file in the borrowing repository should say either /src/base/objects/, or\n> \"../../base/objects\".\n>\n> An easy way to make sure you do not make typo is to go to your borrowing\n> objects directory, and then let your shell completion to type your path,\n> like this:\n>\n>     $ cd /home/jason/source/incremental-bare\n>     $ cd objects\n>     $ echo ../../base-bare/objects >info/alternates\n>\n> While formulating that \"echo\" command line, you would type ../../ <TAB>\n> and pick base-bare, <TAB> and pick objects.\n>\n>   \nAt first, thanks very much.\n\nYes, your concern is right. But here i really put a right relative path \nin the alternates file. Since i can verify it. For example, %> cd \n/home/jason/source/incremental-bare; %> git tag; %>git branch, all \ncommands work well, while if i put a wrong relative path in the \nalternates file, those commands will fail.\n\nThe weird thing is if i operate git commands in the \n/home/jason/source/incremental-bare, all commands work well, it can \nsuccessfully borrow objects (refs) from base-bare via relative path. But \nif i clone a new project-dir from incremental-bare (use incremental-bare \nas local machine dir), it will fail, from the failure output it seems it \ncan't borrow objects (refs) from base-bare. But if i add \"file://\" or \n\"git://\" before incremental-bare, it can work successfully. Do you think \nit is a bug?\n%> git clone /home/jason/source/incremental-bare project-dir // it will fail\n%> git clone file:///home/jason/source/incremental-bare project-dir // \nit will work successfully\n\n\nTo be convenient, i give a reproduce step for this problem:\n1. verify git version on my local machine\nhwang4@wanghui-desktop:mainline$ git --version\ngit version 1.7.6\n\n2. basing on linux-2.6, generate a bare repository linux-2.6-bare\nhwang4@wanghui-desktop:mainline$ git clone --bare linux-2.6 linux-2.6-bare\nCloning into bare repository linux-2.6-bare...\ndone.\nhwang4@wanghui-desktop:mainline$ du -hms linux-2.6-bare/\n950 linux-2.6-bare/\n\n3. make some change in the linux-2.6, and generate a commit\nhwang4@wanghui-desktop:mainline$ emacs linux-2.6/Makefile\nhwang4@wanghui-desktop:mainline$ cd linux-2.6\nhwang4@wanghui-desktop:linux-2.6$ git commit -m \"just test\" ./Makefile\n[master f2c6e4f] just test\n1 files changed, 1 insertions(+), 1 deletions(-)\n\n4. let the linux-2.6-bare as a reference, generate a new INCREMENTAL \nrepositry from linux-2.6\nhwang4@wanghui-desktop:mainline$ git clone --bare --reference \n./linux-2.6-bare/ file:///home/hwang4/work/mainline/linux-2.6 linux-2.6-inc\nCloning into bare repository linux-2.6-inc...\nremote: Counting objects: 5, done.\nremote: Compressing objects: 100% (3/3), done.\nReceiving objects: 100% (3/3), 293 bytes, done.\nResolving deltas: 100% (2/2), completed with 2 local objects.\nremote: Total 3 (delta 2), reused 0 (delta 0)\nhwang4@wanghui-desktop:mainline$ du -hms linux-2.6-inc/\n1 linux-2.6-inc/\n\n{\nhere i must add \"file://\" before source repository, otherwise, the \nmini-tree is full repository instead of incremental, E.G.:\nhwang4@wanghui-desktop:mainline$ git clone --bare --reference \n./linux-2.6-bare/ linux-2.6 linux-2.6-inc\nCloning into bare repository linux-2.6-inc...\ndone.\nhwang4@wanghui-desktop:mainline$ du -hms linux-2.6-inc/\n950 linux-2.6-inc/\n}\n\n5. replace the absolute path in the \nlinux-2.6-inc/objects/info/alternates to the relative path.\nhwang4@wanghui-desktop:mainline$ cd linux-2.6-inc/objects/\nhwang4@wanghui-desktop:objects$ cat info/alternates\n/home/hwang4/work/mainline/linux-2.6-bare/objects\nhwang4@wanghui-desktop:objects$ echo ../../linux-2.6-bare/objects/ > \ninfo/alternates\nhwang4@wanghui-desktop:objects$ cat info/alternates\n../../linux-2.6-bare/objects/\n\n6. verify relative path can work\nhwang4@wanghui-desktop:objects$ git tag\nv2.6.11\nv2.6.11-tree\nv2.6.12\nv2.6.12-rc2\nv2.6.12-rc3\n<snip>\n\n7. from the linux-2.6-inc, we clone a new project, if we don't add \n\"file://\", it will fail\nhwang4@wanghui-desktop:mainline$ git clone \n/home/hwang4/work/mainline/linux-2.6-inc new-project\nCloning into new-project...\ndone.\nerror: object directory \n/home/hwang4/work/mainline/new-project/.git/objects/../../linux-2.6-bare/objects/ \ndoes not exist; check .git/objects/info/alternates.\nerror: refs/tags/v2.6.38-rc8 does not point to a valid object!\nerror: refs/tags/v2.6.38-rc7 does not point to a valid object!\n<snip>\n\n8. but if we add \"file://\" before source repository or change to \nabsolute path in the linux-2.6-inc/objects/info/alternates, i will work \nsuccessfully\nhwang4@wanghui-desktop:mainline$ git clone \nfile:///home/hwang4/work/mainline/linux-2.6-inc new-project\nCloning into new-project...\nremote: Counting objects: 1970908, done.\nremote: Compressing objects: 100% (370377/370377), done.\nReceiving objects: 100% (1970908/1970908), 433.54 MiB | 12.60 MiB/s, done.\nremote: Total 1970908 (delta 1644814), reused 1908550 (delta 1582482)\nResolving deltas: 100% (1644814/1644814), done.\nhwang4@wanghui-desktop:mainline$ ls new-project/\narch COPYING crypto drivers fs init Kbuild kernel MAINTAINERS mm README \nsamples security tools virt\nblock CREDITS Documentation firmware include ipc Kconfig lib Makefile \nnet REPORTING-BUGS scripts sound usr\n"}]}