From: Nguyen Thai Ngoc Duy Date: Mon, 25 Feb 2008 13:17:36 GMT Subject: Re: [PATCH] Move worktree setup out of setup_git_directory* Message-ID: In-Reply-To: <7vr6f1sur3.fsf@gitster.siamese.dyndns.org> On Mon, Feb 25, 2008 at 8:13 AM, Junio C Hamano wrote: > - At startup: > > - If the command always need to run from a repository, call > setup_git_directory(), which would complain and die if you > are outside. > > - If the command can optionally run in a repository, use > setup_git_directory_gently(&nongit_ok); it won't complain > but sets nongit_ok to true if run outside a repository. > > In either case, they return prefix string to be used for > setup_work_tree() later. > > In either case, there is no chdir() done at this point. Interesting. It currently does chdir(). But it is pointless now as worktree should not be accessed until setup_work_tree() is called. setup_git_directory* should not return a prefix at all. > - After calling setup_git_directory(), or you made sure you are > in a repository after callilng setup_git_directory_gently(), > call setup_work_tree(). This will chdir to the top of the > work tree. > > - When you need to know where $GIT_DIR is, call get_git_dir(). > When you need to know where the work tree is, call > get_git_work_tree(). However, it is an error to call these > functions before calling setup_git_directory and > setup_work_tree. I guess I just need to verify your statements and put them to Doc/technical/api-setup.txt ;) -- Duy