git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jason77.wang@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jason Wang <jason77.wang@gmail.com>, <git@vger.kernel.org>,
	Tay Ray Chuan <rctay89@gmail.com>
Subject: Re: help: the question about relative path in the objects/info/alternates
Date: Tue, 2 Aug 2011 15:15:56 +0800	[thread overview]
Message-ID: <4E37A42C.3070702@gmail.com> (raw)
In-Reply-To: <7vr555hvqf.fsf@alter.siamese.dyndns.org>

Junio C Hamano wrote:
> Jason Wang <jason77.wang@gmail.com> writes:
>
>   
>> From the objects/info/alternates part of this URL
>> http://www.kernel.org/pub/software/scm/git/docs/gitrepository-layout.html,
>> it says it will work if alternates has relative path in it.
>>     
>
> It does not just say "relative path", but "relative to the object
> database".  It expresses where the "objects" directory you are borrowing
> from is, relative to your own "objects" directory.
>   
Understand.
> For example, if you have /src/ib/{objects,refs,HEAD} as your repository
> that borrows from elsewhere, say /src/base/, then objects/info/alternates
> file in the borrowing repository should say either /src/base/objects/, or
> "../../base/objects".
>
> An easy way to make sure you do not make typo is to go to your borrowing
> objects directory, and then let your shell completion to type your path,
> like this:
>
>     $ cd /home/jason/source/incremental-bare
>     $ cd objects
>     $ echo ../../base-bare/objects >info/alternates
>
> While formulating that "echo" command line, you would type ../../ <TAB>
> and pick base-bare, <TAB> and pick objects.
>
>   
At first, thanks very much.

Yes, your concern is right. But here i really put a right relative path 
in the alternates file. Since i can verify it. For example, %> cd 
/home/jason/source/incremental-bare; %> git tag; %>git branch, all 
commands work well, while if i put a wrong relative path in the 
alternates file, those commands will fail.

The weird thing is if i operate git commands in the 
/home/jason/source/incremental-bare, all commands work well, it can 
successfully borrow objects (refs) from base-bare via relative path. But 
if i clone a new project-dir from incremental-bare (use incremental-bare 
as local machine dir), it will fail, from the failure output it seems it 
can't borrow objects (refs) from base-bare. But if i add "file://" or 
"git://" before incremental-bare, it can work successfully. Do you think 
it is a bug?
%> git clone /home/jason/source/incremental-bare project-dir // it will fail
%> git clone file:///home/jason/source/incremental-bare project-dir // 
it will work successfully


To be convenient, i give a reproduce step for this problem:
1. verify git version on my local machine
hwang4@wanghui-desktop:mainline$ git --version
git version 1.7.6

2. basing on linux-2.6, generate a bare repository linux-2.6-bare
hwang4@wanghui-desktop:mainline$ git clone --bare linux-2.6 linux-2.6-bare
Cloning into bare repository linux-2.6-bare...
done.
hwang4@wanghui-desktop:mainline$ du -hms linux-2.6-bare/
950 linux-2.6-bare/

3. make some change in the linux-2.6, and generate a commit
hwang4@wanghui-desktop:mainline$ emacs linux-2.6/Makefile
hwang4@wanghui-desktop:mainline$ cd linux-2.6
hwang4@wanghui-desktop:linux-2.6$ git commit -m "just test" ./Makefile
[master f2c6e4f] just test
1 files changed, 1 insertions(+), 1 deletions(-)

4. let the linux-2.6-bare as a reference, generate a new INCREMENTAL 
repositry from linux-2.6
hwang4@wanghui-desktop:mainline$ git clone --bare --reference 
./linux-2.6-bare/ file:///home/hwang4/work/mainline/linux-2.6 linux-2.6-inc
Cloning into bare repository linux-2.6-inc...
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
Receiving objects: 100% (3/3), 293 bytes, done.
Resolving deltas: 100% (2/2), completed with 2 local objects.
remote: Total 3 (delta 2), reused 0 (delta 0)
hwang4@wanghui-desktop:mainline$ du -hms linux-2.6-inc/
1 linux-2.6-inc/

{
here i must add "file://" before source repository, otherwise, the 
mini-tree is full repository instead of incremental, E.G.:
hwang4@wanghui-desktop:mainline$ git clone --bare --reference 
./linux-2.6-bare/ linux-2.6 linux-2.6-inc
Cloning into bare repository linux-2.6-inc...
done.
hwang4@wanghui-desktop:mainline$ du -hms linux-2.6-inc/
950 linux-2.6-inc/
}

5. replace the absolute path in the 
linux-2.6-inc/objects/info/alternates to the relative path.
hwang4@wanghui-desktop:mainline$ cd linux-2.6-inc/objects/
hwang4@wanghui-desktop:objects$ cat info/alternates
/home/hwang4/work/mainline/linux-2.6-bare/objects
hwang4@wanghui-desktop:objects$ echo ../../linux-2.6-bare/objects/ > 
info/alternates
hwang4@wanghui-desktop:objects$ cat info/alternates
../../linux-2.6-bare/objects/

6. verify relative path can work
hwang4@wanghui-desktop:objects$ git tag
v2.6.11
v2.6.11-tree
v2.6.12
v2.6.12-rc2
v2.6.12-rc3
<snip>

7. from the linux-2.6-inc, we clone a new project, if we don't add 
"file://", it will fail
hwang4@wanghui-desktop:mainline$ git clone 
/home/hwang4/work/mainline/linux-2.6-inc new-project
Cloning into new-project...
done.
error: object directory 
/home/hwang4/work/mainline/new-project/.git/objects/../../linux-2.6-bare/objects/ 
does not exist; check .git/objects/info/alternates.
error: refs/tags/v2.6.38-rc8 does not point to a valid object!
error: refs/tags/v2.6.38-rc7 does not point to a valid object!
<snip>

8. but if we add "file://" before source repository or change to 
absolute path in the linux-2.6-inc/objects/info/alternates, i will work 
successfully
hwang4@wanghui-desktop:mainline$ git clone 
file:///home/hwang4/work/mainline/linux-2.6-inc new-project
Cloning into new-project...
remote: Counting objects: 1970908, done.
remote: Compressing objects: 100% (370377/370377), done.
Receiving objects: 100% (1970908/1970908), 433.54 MiB | 12.60 MiB/s, done.
remote: Total 1970908 (delta 1644814), reused 1908550 (delta 1582482)
Resolving deltas: 100% (1644814/1644814), done.
hwang4@wanghui-desktop:mainline$ ls new-project/
arch COPYING crypto drivers fs init Kbuild kernel MAINTAINERS mm README 
samples security tools virt
block CREDITS Documentation firmware include ipc Kconfig lib Makefile 
net REPORTING-BUGS scripts sound usr

      reply	other threads:[~2011-08-02  7:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-01  9:16 help: the question about relative path in the objects/info/alternates Jason Wang
2011-08-01 17:44 ` Junio C Hamano
2011-08-02  7:15   ` Jason Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E37A42C.3070702@gmail.com \
    --to=jason77.wang@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rctay89@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).